老沉香木价格:select * from table1 where id in (select id from table2),

来源:百度文库 编辑:高考问答 时间:2024/04/28 04:12:32
各位大侠:
sql语句能这样写吗?谢谢

select * from table1 where id in (select id from table2 and select id from table3);
下面的回答只有coshxb 正确,附合题意;

dujuan0318:语法错误,
旭坨:并不是说这个语句错误,但不是我要的效果..(我是想"在table2里或者在table3里面,后二表只要有一个里面有,就成了.也许是我表达的不清楚.")
xzp198:乍以为正确,但事实是不正确;

select * from table1
where id in (select id from table2 )
OR id in( select id from table3);

明确一点,这样好像不行。
括号中的两个select送入数据库中跟本就没人认出它来。(我里的“人”指SQL服务器)

select * from table1 where id in((select id from table2)and (select id from table3))

大哥,你的语句都通不过的,我的已经通过了,还说我的不对吗?
你的意思不就是:想找的table1 里的ID既在table2里又在table3里吗??所以你才用AND
而那个你说对的兄弟,用OR ,也算是对了??

你闹啊?

select * from table1 where id in((select id from table2 where id in (select id from table3))

可以这样嵌套着写的,你那样写是错误的,你在分析器里测试下不就知道了

谢谢啊~

大意了~

用and不对,可以用union

select * from table1 where id in (select id from table2 union all select id from table3);