这条SQL语句有简洁一点的吗?

来源:百度知道 编辑:UC知道 时间:2024/06/30 09:56:55
1."select * from 记录表 where 编号=1 and 编号=34 and 编号=56 and 编号=72 and 编号=41 and 编号=..."

如果有很多个条件,上面的SQL语句效率编写效率太费劲了!请教合理的写法.

2.如果条件在另一张表的select 查询结果的“联接编号”字段里,正确的写法应该是怎样的?
"select * from 记录表A where 编号=(***另一张表的select 查询结果的“联接编号”***) "

where 编号 in(1,34,56,72,42)
连接请使用union关键字
例如:
SELECT E_Name FROM Employees_Norway
UNION
SELECT E_Name FROM Employees_USA

select * from biao where 编号 in ('1','34','56'....)

select * from 表A a,表 b where a.编号=b.编号

二楼的很对
!!

in ('1','34','56'....)

第一条语句查询结果为空,and换为or才有需要的结果,关键在于sql的执行效率,应该为“编号”建立索引,sql语句可以用程序自动生成。
第二条语句可以用多表联合查询实现,同意sjyh5201的回答。

where 编号=1 and 编号=34 and 编号=56 and 编号=72 and 编号=41 and 编号=..."
是矛盾的吧
用OR 才对