sql - Whats the simplest way to run a update and select query as one query in mysql? -


i have 2 queries want run @ same time php script.one update query , other select query. update query

update stock_list set qty=qty -1 itembarcode="brms01"; 

and select query

select itembarcode,description,weight,making stock_list  itembarcode="brms01" 

i tried

update stock_list set qty=qty -1 , select itembarcode,description,weight,making stock_list  itembarcode="brms01"; 

and error - (

you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'select itembarcode,description,weight,making stock_list itembarcode=' @ line 1

) appreciated.thank you:)

transactions friend here.

if do

start transaction; update stock_list set qty=qty -1 itembarcode='brms01'; select itembarcode,description,weight,making stock_list  itembarcode='brms01'; commit; 

this update operation, run select query @ same time (rather doing one, other.

edit:

to clarify how should written op's situation

mysqli_query($con,"start transaction;  update stock_list set qty=qty -1 itembarcode='brms01'; select itembarcode,description,weight,making stock_list  itembarcode='brms01'; commit; "); 

this transaction based query need run. on 1 execution, not multiple.


Comments