DELETE FROM MULTIPLE CONDITIONS

I have two conditions in a MySQL DELETE statement. But he does not delete the record.

$sql="DELETE * FROM sportevent.event_registrations WHERE event_registrations.id = '$id' AND event_registration.eventname = $event"; 

Is there something wrong with my request? It works if I use only one WHERE clause, but I need to use two.

+4
source share
2 answers

I suspect the following:

 event_registration.eventname = $event 

it should be

 event_registrations.eventname = $event 

After all, you used the plural form in both the from clause and the other part of the where clause.

Also note that only one of your parameters is quoted - it is not clear to me how you provide the parameters, but, of course, you must be consistent.

+6
source

try it

 $sql="DELETE FROM sportevent event_registrations WHERE event_registrations.id = '$id' AND event_registrations.eventname = $event"; 
+2
source

All Articles