I’m a little confused about checking values in a database. What I want to do is see if a tuple such as the following exists:
job_num |item_code |invoice_num
------------------------------------
94834 |EFC-ASSOC-01|
The invoice_num is not null, it’s blank: ” “.
What I want is to find if such an entry exists, where the invoice_num is ” ” and update it with a number entered into a textbox. I’m a little confused about if statements and cases in SQL, so if someone could point me in the right direction, that would be great!
One way to find such rows (or tuples) would be a query like:
or follow @Ben’s advice if the empty string is a problem. Then you can do an update:
However, the problem with this approach is that if you’re not using the primary key to choose a row in the update statement, multiple rows could get updated (similarly, the select statement could return multiple rows). So, you’ll have to look at the database schema and determine the primary key column(s) of the table, and make sure that all of the primary key columns are used in the WHERE clause of the update. If you just do
all rows with that value of invoice_num will be updated, which may not be what you want.