Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Howto make view with left outher join

Status
Not open for further replies.

sciencer

Technical User
Jan 7, 2004
17
NL
Hi

If the fulling problem

If got 2 tables

One with companies en one with cities.

in my table compy i've got three numbers. These nummers are the same as a number of a city in the table cities.
for example

Table company
Mycompanie 1, 2,3


table cities
1, Amsterdam
2, New York
3, London

Can anyone tell met how i can show with sql

Mycompany Amsterdam, New york, London

Raymond

 
If I'm reading your explanation correctly, I don't think I'd do this with a LEFT OUTER JOIN, unless there could be entries in your company table with no corresponding city entry. Do get what I think you are looking for, I'd do the following...

SELECT c.company, c1.city, c2.city, c3.city
FROM Company c,
City c1,
City c2,
City c3
WHERE c.city1 = c1.city
and c.city2 = c2.city
and c.city3 = c3.city

I'm not sure what your exact column names are, but this is a general idea.

Jim
 
Well I have entries in my compay table with no corresponding city entry. So i think I have to use the left outher Join. but I don't how. Can anyone halp me

Raymond
 
SELECT
c.company,
c1.city,
c2.city,
c3.city
FROM Company c
left join City c1 on c.city1 = c1.city
left join City c2 on c.city2 = c2.city
left join City c3 on c.city3 = c3.city
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top