>Hi all
>
>I need to select some records from table 'A' that have to meet a condition in table 'B', like,
>
>Table A Table B
>---------------------------- ------------------------
>CodDoc Number CodArt CodDoc Filter
>FACC 00001 001.001 FACC 1
>FACC 00001 001.002 NCCC 1
>FACC 00002 001.001 RCCC 3
>NCCC 00001 001.001
>RCCC 00001 001.001
>
>
>I need to select from table A only the records that match table B with Filter = 1, in this case only the records that have FACC,NCCC and not RCCC
>
>Thank's
>
>João Batista
One possibility is a sub-query:
select * from TableA where CodDoc in (select CodDoc from TableB where Filter = 1)
You can also simply join the two tables, and filter the results:
select TableA.*, TableB.Filter;
from TableA join TableB on TableA.CodDoc = TableB.CodDoc;
where Filter = 1
HTH,
Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)