请教高手!!!SQL语言问题

来源:百度知道 编辑:UC知道 时间:2024/05/22 18:28:11
以下语句,提示:missing expression是怎么回事?哪里错了?拜托高手不吝赐教!

select count(*) from db where 1=1 and XH='12060403' and select xkkh,kcmc from CJB where XH='12060403' and '1'='1'
我想大概是后面多出一个select语句的问题,请问如何一次执行多个SQL语句呢?

sql语句没有这么写的, 这很明显是两条语句.
如果你都想执行的话, 请分开执行, 或者用分号隔开,
但不能同时执行两个查询的操作, 查询出来的结果需要显示出来的.

如果count(*) ,xkkh,kcmc 这三个字段你都想查出来, 那么请这么写:
select xkkh,kcmc,(select count(*) from db where 1=1 and XH='12060403') from CJB where XH='12060403' and '1'='1'
或者
select xkkh,kcmc,(select count(*) from db where 1=1 and XH=cjb.xh) ccount from CJB where XH='12060403' and '1'='1'

执行一下这语句,发现没有什么意义, 你第一条语句只有一个值, 但第二条语句会有一个以上的记录(当然如果是一条的话就有意义了)

select count(*) from db where 1=1 and XH='12060403' and select xkkh,kcmc from CJB where XH='12060403' and '1'='1'
因为不知道您的目的,所以没法修正您的语句。但从字面的来说这个语句就是不对的。
语句中的几个问题:
一、1=1 在AND 组合的条件占是无效的。
二、子查询要用扩号扩起来。

有什么具体要求你再发消息吧

select xkkh,kcmc from CJB where XH='12060403' and '1'='1'

这个子查询这么能当成条件使用呢

应该是:
** in(select xkkh,kcmc from CJB where XH='12060403&