START TRANSACTION;
SELECT * FROM tab1 WHERE 1 LIMIT 1;
DELETE FROM tab1 WHERE id="{HOW TO ACCESS ID FROM THE SELECT ABVOE?}"
COMMIT;
我想获取所选行的ID,删除它并将id返回给PHP (mysql_fetch_array());
答案 0 :(得分:3)
DELETE FROM tab1 WHERE id = (SELECT id FROM tab1 LIMIT 1);
你的WHERE
毫无意义。我不知道查询的目的,但这是你怎么做的。
或者,您可以将第一个查询的结果保存在会话变量中。
SET @result = (SELECT id FROM tab1 LIMIT 1);
DELETE FROM tab1 WHERE id = @result;