Link to home
Start Free TrialLog in
Avatar of K3HT
K3HT

asked on

Query Question

I am trying to select records from one table if a field's contents are in another table.  This is what I was thinking, although it did not work

SELECT CLIENT,LOCIX,ACCT,STATUS, FROM RMAST WHERE STATUS IN (SELECT STATUS FROM INWOSTAT) AND CLIENT = 'XBA'

Any ideas on how I would write this query to do what I am looking for?
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of VoteyDisciple
VoteyDisciple

That looks correct.  Are you using an older version of MySQL that doesn't support subqueries?

You can fall back on...

SELECT CLIENT, LOCIX, ACCT, STATUS
FROM RMAST
LEFT JOIN INWOSTAT ON (INWOSTAT.STATUS = RMAST.STATUS)
WHERE CLIENT = 'XBA' AND INWOSTAT.STATUS IS NULL;
Wow, not only did I misread the question, I then managed not to hit Submit 'til you already answered.  Sorry about that!
Avatar of K3HT

ASKER

np, thanks for trying.