September 14, 2005 at 8:40 am
Hi. I need to run a query that gets info from one table, and then if a certain field is equal to a certain value, get something from another table.
Here's the example, from table 'Account' I select
Name, Email, Accountlevel
Then, IF accountlevel is 10, get the value 'PhoneNumber' from table 'AdminInfo'.
Is this doable in one statement?
Thanks.
September 14, 2005 at 8:48 am
Just do the select like if you wanted to always get that phone number. Then write this :
CASE when accountlevel = 10 THEN AdminInfo.PhoneNumber ELSE 'Another field, or null..' END as PhoneNumber
September 14, 2005 at 11:29 pm
Try:
SELECT A.Name, A.Email, A.Accountlevel, I.PhoneNumber
FROM Account AS A
LEFT JOIN AdminInfo AS I ON A.<your linking field> = I.<your linking field>
AND A.AccountLevel = 10
Andy
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply