开发者

Weird behavior of mysqli->query for multiple DELETE

I am running following query by using mysqli->query but despite of showing affected rows removing correct records,MYSQL is not removing the records. The sam开发者_开发问答e query runs perfect on command line.

DELETE m,s FROM t1 m
LEFT JOIN t2 s ON t1.sbid = t2.sb_message_id
WHERE m.sbuid = 11

mysqli->affected_rows gives correct count but its weird that records are not being removed.

OK just checked that even a single Delete query is not being executed. Let me also clear that I am deleting within a loop.


Looking at this SQL it is very clear at it is illformed. The format expected for delete statement is:

Delete from TableName where condition

So there is no field name between Delete and from allowed. The technical reason is delete deletes rows not fields.

In case you want to "delete" fields, ie, change value to null then you need to update the record and set values for the fields to null.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜