Forum Moderators: open

Message Too Old, No Replies

SQL Statement Question for ASP page

         

kevinj

3:09 pm on Jun 8, 2003 (gmt 0)

10+ Year Member



I need a SQL statement that will delete records from a database if 2 conditions are true. The performer_id field must be equal to the Session(performer_id) and the june_confirm field must NOT be equal to 1. This is what I have so far:

Set DS = DB.execute("SELECT * FROM music WHERE performer_id=" & Session("PERFORMER_ID"))

While not DS.eof
JUNE_CONFIRM = DS("june_confirm")

If JUNE_CONFIRM <> 1 Then

DB.execute("DELETE

DS.movenext()
Wend

I'm not sure how to write the delete execution for the record. Thanks for any help.

kevinj

3:10 pm on Jun 8, 2003 (gmt 0)

10+ Year Member



Forgot to End the if statement:

Set DS = DB.execute("SELECT * FROM music WHERE performer_id=" & Session("PERFORMER_ID"))

While not DS.eof
JUNE_CONFIRM = DS("june_confirm")

If JUNE_CONFIRM <> 1 Then

DB.execute("DELETE

End If

DS.movenext()
Wend

musicales

7:32 pm on Jun 8, 2003 (gmt 0)

10+ Year Member



Isn't it just

sql="delete FROM music WHERE performer_id=" & Session("PERFORMER_ID")) & " and JUNE_CONFIRM <> 1"

DB.execute(sql)

sharbel

8:19 pm on Jun 8, 2003 (gmt 0)

10+ Year Member



Yep, no need to iterate through the recordset, just handle it all in SQL statement.

kevinj

9:10 pm on Jun 8, 2003 (gmt 0)

10+ Year Member



Thanks guys that works perfect. I thought there was a way to combine those statements. Really do appreciate your help.

Kevin