sql - How can I make count() as a condition when I update a table? -


select count(tableid)  diningtable isavail = 1; 

i can "number of table" logically, want use number in next sql query.

update diningtable set isavail = 0 tableid = 11 - [should number of table, result above]; 

what can do?

make sure put isnull() check avoid null error if first select return 0 rows

update diningtable set isavail = 0 when tableid = 11 - (select isnull(count(tableid),0) diningtable isavail = 1); 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -