ngplayground ngplayground - 1 year ago 76
SQL Question


Trying to get the following to work but for the life of me i cannot get this working.

Could someone assist?

DELETE FROM 'content' WHERE note_id = '7' AND WHERE userid = '1'
DELETE FROM 'note' WHERE id = '7' AND WHERE userid = '1'

I need to delete a record from each table where it checks that the user is actually that user but im getting syntax error when I run the query

I Receive the following when I remove the 2nd WHERE.

SQL Error (1064): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntac to user near 'DELETE FROM
WHERE id ='7' AND userid = '1"
at line 2

Apologies turns out I added an extra space before the script got to here

Answer Source

Only 1 WHERE needed, try this:

DELETE FROM content WHERE note_id = '7' AND userid = '1'
DELETE FROM note WHERE id = '7' AND userid = '1'