PDA

View Full Version : small problem with SELECT


angiras
06-02-2003, 08:45 PM
I don't know where to post this thread


I have 2 tables (access 2000)

--------------------------

tableOne
id_one [numAuto]
one [text]

tableTwo
id_two [numAuto]
id_one [numeric]
two [text]

--------------------------

id_one...one
1............A
2...........B
3...........C
4...........D


id_two..id_one...two
1...........1...........A_1
2...........1...........A_2
3...........2...........B_1
4...........3...........C_1
5...........3...........C_2
6...........3...........C_3

--------------------------

with this request :

SELECT tableOne.one, Last(tableTwo.two) AS lastTwo
FROM tableOne INNER JOIN tableTwo ON tableOne.id_one = tableTwo.id_one
GROUP BY tableOne.one

I get :

one......lastTwo
A...........A_2
B...........B_1
C...........C_3

and I want to get :

one......lastTwo
A...........A_2
B...........B_1
C...........C_3
D...........

--------------------------

I want each line from tableOne even if there is no correspondent line in tableTwo

allida77
06-02-2003, 08:59 PM
Try:

Left Outer Join tableTwo ON tableOne.id_one = tableTwo.id_one


Which will return all the rows from table tableOne with/without a match and only the rows from table tableTwo that match.

angiras
06-02-2003, 09:02 PM
it works ! at once !!

thanks a lot !!!