mysql - What is wrong with this INSERT MAX+1 query? -


i'm having problem query:

insert invoices(invuid, linenumber) values (?, select(select max(linenumber)+1 invoices invuid=?))

it keeps saying: "general error: 1093 can't specify target table 'invoices' update"

your syntax invalid, use insert ... select , remove values part this:

insert invoices(invuid, linenumber)  select ?, max(linenumber)+1 invoices invuid=? 

Comments

Popular posts from this blog

command line - Use qwinsta in PowerShell ISE -

java - Incorrect order of records in M-M relationship in hibernate -

Python website log in: BIG-IP can not find session information in the request -