Reputation: 737
I'm having problem with this query:
INSERT INTO invoices(invuid, linenumber) VALUES (?, SELECT(SELECT max(linenumber)+1 FROM invoices WHERE invuid=?))
It keeps saying: "General error: 1093 You can't specify target table 'invoices' for update"
Upvotes: 1
Views: 24
Reputation: 79929
Your syntax is invalid, use INSERT INTO ... SELECT
and remove the values
part like this:
INSERT INTO invoices(invuid, linenumber)
SELECT ?, max(linenumber)+1 FROM invoices WHERE invuid=?
Upvotes: 1