急!asp达人,如何正确使用查询语句(where or),在线等~~~!

来源:百度知道 编辑:UC知道 时间:2024/07/07 12:48:25
帮我把下边的SQ语句改下~!(也就是OR的用法,用的是ASP~)

rs1.open "select * from tblproduct where season_ID="&request("id") or price_ID="&request("id") or price_ID="&request("id") or style_ID="&request("id") or color_ID="&request("id"),conn,1,3

rs1.open "select * from tblproduct where season_ID="&request("id")&" or price_ID="&request("id")&" or price_ID="&request("id")&" or style_ID="&request("id")&" or color_ID="&request("id")&"",conn,1,3

在SQL中or会遍历整个表,查询起来会增加服务器压力和反应速度,最好能少用还是少用吧

select * from tblproduct where season_ID="&request("id") and (price_ID="&request("id") or price_ID="&request("id")) and style_ID="&request("id") and color_ID="&request("id")
不知道你是不是要这个。
你也没有说明你到底要什么效果?

where 表示查询满足条件的 后面跟条件
or 表示满足其一,相当于或者的意思
整个SQL语句的一生是;查询所有字段 从tblproduct表中 满足条件 1 或者 2 或者3 或者 4
整理一下就是 从tblproduct表中 查询满足条件1或者条件2或者条件3或者条件4的所以字段。