Reputation: 547
Ok I have two tables. First table is fmp_leads
. Second table is sic_codes
fmp_leads
has a bunch of lead data, including a column called sic_code
sic_codes
has 3 columns (id, sic_code, good_bad
)
I want to run this:
SELECT *
FROM fmp_leads
WHERE (
fmp_leads.sic_code MATCHES sic_codes.sic_code
AND sic_codes.good_bad = good
)
I realize that statement above isn't real, I'm just not sure how to perform the WHERE statement.
Upvotes: 1
Views: 384
Reputation: 7835
You probably want to JOIN
the two tables ON
the field you care about and use =
in your WHERE
clause:
SELECT * FROM fmp_leads fmp
JOIN sic_codes sic
ON fmp.sic_code = sic.sic_code
WHERE sic.good_bad = 'good';
Upvotes: 3
Reputation: 292
well this is another way to get data you want to,
when you are trying grab data from that table use where a.sic_code=b.sic_code
Here is all query
select * from fmp_leads a, sic_codes b
where a.sic_code=b.sic_code and b.good_bad ='good'
Note : Just use operator and, or based on you need it and to prevent repeatation using order by id from main table
Upvotes: 0