I have 3 columns(id,parent,value) with some data and this query:
SELECT * FROM test WHERE id = (
SELECT parent FROM test WHERE id=2 AND value='value' LIMIT 1
);
The query above works great.
Now how can I delete instead of select that id in one query?
You cannot delete from a table and select from that same table in a subselect.
You can however use that table in a self-join.
You cannot use
limitnotorder byin a joined delete statement.It’s either the join or the limit/order by, take your pick.
See: http://dev.mysql.com/doc/refman/5.5/en/delete.html