sql server - How to use SQL conditional statements -


When executing an update query, I must delete a row based on values ​​in the column. Here's the code:

  UPDATE tag SET tag_count = tag_count - 1 WHERE tag_ID = 1 if the tag is counted & lt; Remove 1 from tag where tag_ id = 1  

this query gives me an error.

Edit I am using Inline SQL with C # sql server

In general, the best option updates and a transaction in these cases:

BEGIN transfer; Tag tag tag with tag ccc_count = tag_count - 1 WHERE tag_id = 1 with DELETE tag where tag_ id = 1 and tag_account & lt; 1; Committed transactions;

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -