请问这个查询语句写法存在什么问题吗?
我在用asp+server2000写网页的时候,需要根据某些条件用查询语句来列出结果。
<%
dim sql
dim rs
set conn=Server.CreateObject("ADODb.Connection")
Set rs= Server.CreateObject("ADODb.Recordset")
conn.open "driver={SQL Server};server=server;uid=sa;pwd=aa;database=bb"
sql="select * from VopMSsql where eid='"&session("pin")&"' and hourofday<>''and minuteofhour<>''order by id desc"
response.write sql
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<tr><td colspan='4' align='center'><font size='3' color='red'>没有信息!</td></tr>"
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
%>
<%
do while not rs.eof
%>
<tr>
<td><%=rs("yearfrom")%></td>
<td><%=rs("yearto")%>年</td>
<td><%=rs("hourofday")%></td>
<td><%=rs("minuteofhour")%></td>
</tr>
<%
rs.movenext
loop
%>
我想把数据库中所有符合条件的记录都列出来,但上面的sql语句只是列出最后一条记录,如果我把上面的sql语句改为:sql="select * from VopMSsql where eid='"&session("pin")&"' and hourofday<> order by id desc" 就能正确表达我的意思,全部列出符合条件的记录,请问问题出现在哪里,怎么解决呢?如果后面的条件更多,怎么办?sql查询的where条件不能多带几个and吗?
<%
dim sql
dim rs
set conn=Server.CreateObject("ADODb.Connection")
Set rs= Server.CreateObject("ADODb.Recordset")
conn.open "driver={SQL Server};server=server;uid=sa;pwd=aa;database=bb"
sql="select * from VopMSsql where eid='"&session("pin")&"' and hourofday<>''and minuteofhour<>''order by id desc"
response.write sql
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<tr><td colspan='4' align='center'><font size='3' color='red'>没有信息!</td></tr>"
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
%>
<%
do while not rs.eof
%>
<tr>
<td><%=rs("yearfrom")%></td>
<td><%=rs("yearto")%>年</td>
<td><%=rs("hourofday")%></td>
<td><%=rs("minuteofhour")%></td>
</tr>
<%
rs.movenext
loop
%>
我想把数据库中所有符合条件的记录都列出来,但上面的sql语句只是列出最后一条记录,如果我把上面的sql语句改为:sql="select * from VopMSsql where eid='"&session("pin")&"' and hourofday<> order by id desc" 就能正确表达我的意思,全部列出符合条件的记录,请问问题出现在哪里,怎么解决呢?如果后面的条件更多,怎么办?sql查询的where条件不能多带几个and吗?
...全文
相关推荐
MySQL查询语句写法示例
数据库MySQL的常用查询语句和一些基本的查询语句,希望对你有帮助
PLSQL常用查询语句
数据库的查询语句很常用,这是一个学习笔记,虽然有班门弄斧之嫌,但是对于初学者还是比较有用的,无需资源分,欢迎下载
浅谈pymysql查询语句中带有in时传递参数的问题
直接给出例子说明: cs = conn.cursor() img_ids = [1,2,3] sql = "select img_url from img_url_table where id in %s" cs.execute(sql, (img_ids, )) # 直接传递元组包裹列表即可 补充知识:Python将多行数据处理成SQL语句中where条件in(‘ ‘,’ ‘,’ ‘)的数据 在工作中有时需要查询上万行指定的数据,就会用到SQL语句中 select * from table1 where table1.name in (‘ ‘ , ‘ ‘ ) 的条件查询,所以自己写了个小小
总结简单PLSQL查询语句
总结简单PLSQL查询语句,包括删除,in,逻辑语句,排序等
ACCESS数据库里的一些查询语句用法
ACCESS数据库里的一些查询语句用法! 值得下载看看!资源免费,大家分享!! 更多免费资源 http://ynsky.download.csdn.net/



