|
蓝森林 http://www.lslnet.com 2006年8月25日 8:28
[asp]如何做到数据库里相同的记录只提一次
数据库里提记录的时候,遇到相同的记录只提一次,这怎么来写呢,请大家指教。
比方说:
<%set ra=server.CreateObject("adodb.recordset")
ra.open "select * from shop_anclass order by anclassidorder",conn,1,1
if ra.eof then
else
while not ra.eof%>
<tr><td><%=ra("anclass")%></td></tr>('就在这里anclass在数据库里有相同的记录)
<%ra.movenext
wend
end if
%> |
写成查询语句,"...where anclass='准备添加的值'"..."
给rs.addnew加个判断,
....
if rs.eof then
rs.addnew
rs("anclass")=准备添加的值'
....
rs.update
end if
... |
不是提交保存记录,是取出记录怎么办?
按这例子
<%set ra=server.CreateObject("adodb.recordset")
ra.open "select * from shop_anclass order by anclassidorder",conn,1,1
if ra.eof then
else
while not ra.eof%>
<tr><td><%=ra("anclass")%></td></tr>('就在这里anclass在数据库里有相同的记录)
<%ra.movenext
wend
end if
%>
我提出的数据是:
一级类
二级类
二级类
一级类
一级类
这样的话,就会有相同的记录被提取,应该是判断,可我不知道应该怎么写这个判断句,如果遇到提取的记录与上一记录相同则指针下移。怎么用什么函数呢? |
sql = "SELECT distinct(OrderNumber),AdminChecked,B_PostTime FROM Basket WHERE UserName='" & UserName & "' And UserChecked=" & pageid
里面的 distinct(OrderNumber) 就是将 字段 OrderNumber只取不重复的 |
谢谢,我试试,好了,太感谢你。 |
|