View Single Post
  #1 (permalink)  
Old 07-07-2008, 05:06 PM
Unregistered
 
Posts: n/a
Default ANY dialect question:

select values from the 2 different table


Sample tables (company_id RK companies.id):
Code:
Companies
id    company
1    …
2    …
3    …

    Locations
id    company_id    location    revision
1    1    …    1
2    2    …    1
3    1    …    2
4    1    …    3
5    2    …    2
6    1    …    4
How to write an SQL query to select values from the following columns (companies.company, locations.location) where locations.revision value will be the highest for each company

I try
Select distinct companies.company, locations.location from Companies, Locations where companies.id=Locations.company_id ...

How? thanks.
Reply With Quote

ANSWER(S):