SQL嵌套查询。。

来源:百度知道 编辑:UC知道 时间:2024/05/29 00:52:10
在ASP.NET里
string sql="select * from 表1 where id=(select ID from 表2)";
这条语句是不可以用的,请问有什么方法代替么?
在SQL PLUS里select * from 表1 where id=(select ID from 表2)是可以执行的。

sql="select * from 表1 where id=(select ID from 表2)";这个语句是必须保证你 的id必须是一个,要不执行不了,可以改成
sql="select * from 表1 where id in(select ID from 表2)";
就可以了,用的好了的话快给分吧

select a.* from biao1 a,biao2 b where a.id=b.id

或者:select * from 表1 where id in (select ID from 表2)

select * from 表1 where id in(select ID from 表2)

select * from 表1 where id in (select ID from 表2)