Forum Moderators: coopster

Message Too Old, No Replies

MySQL delete specific rows

correct syntax?

         

henry0

7:48 pm on Nov 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello
I cannot find or remember the correct syntax to del specific rows
for example:
$sql = "delete from test_table where id ='$id' ";

I know that if send the above I will del it all

but how do a write it in order to del only specified rows
delete aa, bb, cc etc... from .. where ...
of course I do not want to remove the row but its content only!
thanks

regards

Henry

ergophobe

8:07 pm on Nov 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Actually, that syntax is good and it will not delete all rows, only the one(s) where id matches $id.

If you want to delete specifc data from a row, but retain the row, you need to use update [dev.mysql.com] rather than delete [dev.mysql.com]

So in that case, it would be

UPDATE table_1 SET col_name1=`$val_1`, col2=`$val_2` WHERE id=$id

or some such thing.

Tom

henry0

8:17 pm on Nov 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Tom
I knew I was not looking at the correct one
it was not making sense, I was focussing on del when I should have thought about updating

regards

henry