LMSouq
database Open

How do I put an 'if clause' in an SQL string?

JO
John Ernest Guadalupe
1 month ago
3 views
Problem Description
So here's what I want to do on my _MySQL_ database. I would like to do: SELECT * FROM itemsOrdered WHERE purchaseOrder_ID = '@purchaseOrdered_ID' AND status = 'PENDING' 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: UPDATE purchaseOrder SET purchaseOrder_status = 'COMPLETED' WHERE purchaseOrder_ID = '@purchaseOrder_ID' How would I be able to make this process a little shorter?

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base