Jump to content

mySQL row delete..


mikey3521

Recommended Posts

I have a table with the following values:

 

id    to    from    subject    read

 

with the following info

 

1    2    6          hey!            1

2    2    4        wjat?            1

3    8    5        test!            1

 

the "from" is the users 'id' on a different table, now on running a script, I want it to search this table for any row that has "2" in the from field, so any row with a msg user 2 has sent, and delete it. Heres what I have.

 

("DELETE FROM messages WHERE to=2");

 

It returns no erros, the rest of the script runs, and it dosn't delete the rows??

Link to comment
https://forums.phpfreaks.com/topic/55918-mysql-row-delete/
Share on other sites

subject is OK as a field name.  to, from, and read are all reserved words and you should not use them as field names or table name.  The right way to fix the problem is to avoid using reserved words as names.  The sloppy way is to surround each one with `backticks`.

 

Do it right - see http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

Link to comment
https://forums.phpfreaks.com/topic/55918-mysql-row-delete/#findComment-276243
Share on other sites

I see what you mean, but given the context of the table, aren't to and from the most appropriate names for the fields? It seems a whole stack easier to put backticks around the words than change the to msgto and msgfrom to me. Guess thats just personal opinion though.

Link to comment
https://forums.phpfreaks.com/topic/55918-mysql-row-delete/#findComment-276273
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.