Home > Archive > MS SQL Server MSEQ > September 2005 > Join syntax?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Join syntax?
DonSQL2222

2005-08-29, 8:24 pm

I'm not sure if this is a join problem or even if it can be done.

The english part of the query will be requesting cagegoires="Cat2"
and return the matching records in table1, plus return all the other
categories that belong to the set in table 2.

should return two records..
1 document1 Cat1 Cat2 Cat3
2 document2 Cat1 Cat2


table 1
ID int DOC char(20)
1 document1
2 document2

table 2
ID int Category char(4)
1 Cat1
1 Cat2
1 Cat3
2 Cat1
2 Cat2

Thanks,
Don

table 1
1 do
Hugo Kornelis

2005-09-02, 8:24 pm

On Mon, 29 Aug 2005 13:56:36 -0700, DonSQL2222 wrote:

>I'm not sure if this is a join problem or even if it can be done.
>
>The english part of the query will be requesting cagegoires="Cat2"
>and return the matching records in table1, plus return all the other
>categories that belong to the set in table 2.
>
>should return two records..
>1 document1 Cat1 Cat2 Cat3
>2 document2 Cat1 Cat2

(snip)

Hi DonSQL2222,

To get the basic information, but not in the format you specified above:

SELECT t1.ID, t1.DOC, t2.Category
FROM table1 AS t1
INNER JOIN table2 AS t2
ON t2.ID = t1.ID
ORDER BY t1.ID, t2.Category

Modifying the format to your desired form should be done at the front
end. Presentation is not a task for the database in a tiered
architecture.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com