March 31, 2009 at 1:45 pm
Table 1
GroupName GroupID GroupDesc
Group1 1Item1
Group1 2Item2
Group1 3Item3
Group1 4Item4
Group1 5Item5
Group1 6Item6
Table 2
ProfileID ProfileDate GroupID
A 1/1/2009 1
A 1/8/2009 2
A 3/7/2009 3
B 1/2/2009 4
C 3/2/2009 2
A 2/9/2009 6
I want to join them to look like this for ProfileID = "A"
GroupName GroupID GroupDesc ProfileID ProfileDate GroupID
Group1       1          Item1          A        1/1/2009  1
Group1       2          Item2          A        1/8/2009  2
Group1       3          Item3          A        3/7/2009  3
Group1       4          Item4
Group1       5          Item5
Group1       6          Item6          A        2/9/2009  6
However, my table looks like this (items 4 & 5 are missing)
GroupName GroupID GroupDesc ProfileID ProfileDate GroupID
Group1 1Item1 A 1/1/2009 1
Group1 2Item2 A 1/8/2009 2
Group1 3Item3 A 3/7/2009 3
Group1 6Item6 A 2/9/2009 6
My join statement is this:
SELECT *
FROM Table1 LEFT OUTER JOIN Table2
ON Table1.GroupID = Table2.GroupID
WHERE (Table2.ProfileID = 'A')
March 31, 2009 at 2:08 pm
Hi
If your criterion shall be used for the join you have to put it there:
SELECT *
FROM Table1 LEFT OUTER JOIN Table2
ON Table1.GroupID = Table2.GroupID Table2.ProfileID = 'A'
Greets
Flo
March 31, 2009 at 2:23 pm
Thanks for your reply!
When I put in the code above, I get a syntax error.
March 31, 2009 at 2:27 pm
SELECT
*
FROM
Table1
LEFT OUTER JOIN Table2
ON (Table1.GroupID = Table2.GroupID
AND Table2.ProfileID = 'A');
March 31, 2009 at 2:32 pm
Dang! Sorry... I shouldn't try blind typing...
Thanks for correction Lynn!
Greets
Flo
March 31, 2009 at 2:35 pm
No prob, Flo. Easily corrected error.
March 31, 2009 at 2:42 pm
AWESOME... Worked like a charm!
Thanks guys!! :w00t:
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply