How do I conditionally select a field from one of two tables?
- by freakwincy
I have two tables invoices and pending_payments both of which have the following rows in common: invoice_id and balance. I want to do a select in MySQL that'll work thus:
[pseudo-code]
if(invoice_id exists in pending_payments table) {
select balance from pending_payments where invoice_id = yadayadayada
} else {
select balance from invoices where invoice_id = yadayadayada
}
Is this even doable in MySQL? If so, how?