Skip to content
Advertisement

How do I put an ‘if clause’ in an SQL string?

So here’s what I want to do on my MySQL database.

I would like to do:

If that would not return any rows, which is possible through if(dr.HasRows == false), I would now create an UPDATE in the purchaseOrder database:

How would I be able to make this process a little shorter?

Advertisement

Answer

For your specific query, you can do:

However, I might guess that you are looping at a higher level. To set all such values, try this:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement