SQL Statement for more than one type of code in the same column -
i have basic query selecting 1 table , joining table. on second table using filter on column exclude records don't want.
the first table basic, things name, id, address, etc. contains no duplicates. second table (product table) more this:
id code desc desc2 ----------------------------------------- 94 pg county code sydney, ne 95 pg county code monticello, ut 96 pg county code vernal, ut 97 pg county code other, out of state pg county code no data 1 ps race code spanish american 2 ps race code other - white 3 ps race code black 4 ps race code american indian
and select looks this:
select a.*, b.desc custtable inner join prod_table b on a.id = b.id b.code = 'pg'
i have need records prod_table code = 'ps'.
is there way in 1 query or need make table 'ps' records , query that?
edit: sorry being confusing, trying simplify things made worse. edited post actual data table, maybe help.
select a.*, b.desc custtable inner join prod_table b on a.id = b.id b.code = 'pg' or b.code = 'ps'
or
select a.*, b.desc custtable inner join prod_table b on a.id = b.id b.code in('pg','ps')
Comments
Post a Comment