I am trying to create a query, that will check if it exist in a table, if it exist, it will just add one to quantity qty
else it will insert from a selecting from other table, in my case temp_sales
here's my sql so far.
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; BEGIN TRANSACTION; IF EXISTS ( SELECT pid FROM temp_sales WHERE barcode = '4800556410652' ) BEGIN UPDATE temp_sales SET qty = qty + 1 WHERE barcode = '4800556410652' END ELSE INSERT INTO temp_sales ( 0, ( SELECT products.ID, products.product_sprice as price, 1, 1 * price, '4800556410652', '101', 'admin' WHERE barcode = '4800556410652' ) ) END COMMIT TRANSACTION;
I have been following this stackoverflow answer from UPDATE if exists else INSERT in SQL Server 2008 but I have no luck.
MySQL error #104 #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRANSACTION' at line 1
what did I do wrong?
EDIT
PL: vb.net DB: MySQL(xampp)