注册 登录
编程论坛 SQL Server论坛

SQL语句可以这么写么?

champion1983 发布于 2006-12-30 23:52, 526 次点击

select * from products where type_id='"&"what is new"&"' or type_id='"&"fish"&"' or type_id='"&"lures"&"' order by class_id


这样写可以么?有没有违反sql语句的规范?

7 回复
#2
xu20002006-12-30 23:57
应该可以,不过为什么不用in?
#3
champion19832006-12-31 10:35
因为表里的这一列还有其他的值,我只想要这几个值

前辈的意思是
select * from products where type_id in ('"&"what is new"&"','"&"fish"&"','"&"lures"&"') order by class_id

这样么?
#4
bygg2006-12-31 14:48
select * from products where type_id in ('what is new','fish','lures') order by class_id

这样就行了.

#5
LouisXIV2006-12-31 14:52
以下是引用bygg在2006-12-31 14:48:34的发言:
select * from products where type_id in ('what is new','fish','lures') order by class_id

这样就行了.


他的值是从外部取得的,按他自己写的即可

#6
champion19832006-12-31 15:11
哦~谢谢前辈指点
#7
myth_sky2007-01-01 01:32
哦。。。学下~~
#8
bygg2007-01-01 14:00
以下是引用LouisXIV在2006-12-31 14:52:05的发言:


他的值是从外部取得的,按他自己写的即可

哦,知道了.

1