Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select Statement
Message
From
20/05/2004 22:07:25
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
20/05/2004 21:48:16
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00905875
Message ID:
00905880
Views:
10
>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)
Previous
Reply
Map
View

Click here to load this message in the networking platform