Tuesday, 20 August 2013

Using an IF() based on a query result

Using an IF() based on a query result

I'm trying to use an IF() is mySQL where the structure looks something
like this:
if(
phone_number LIKE '%992%' (SELECT phone_number FROM db.phonebook WHERE
country='UK'),
SELECT xxx FROM xxx WHERE xxx,
SELECT xxx FROM xxx WHERE xxx
)
I'm trying to achieve:
IF (if you manage to find a phone number in the 'UK' phonebook that
looks like '992'),
THEN (run the following XXX query),
ELSE (run the following YYY query)
This doesn't work, the syntax is obviously wrong. Would appreciate you
advice.

No comments:

Post a Comment