Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
georous
Starting Member
12 Posts |
Posted - 2007-01-28 : 07:56:09
|
| Hi! my db schema is the followingTable CCut_item ,ut_refTable KWDSut , deTable KWDS_PLUSut ,idTable UT_2_CONSIDERutEach CC.ut_item and CC.ut_refhas a KWDS.utI am trying to combine each ut_item's KWDS.de with the ut_ref's KWDS.deut_item-> KWDS.de | ut_ref->dehow can i make a select statement for that?I Hope i was clear enoughThank you! |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-28 : 08:07:17
|
quote: Each CC.ut_item and CC.ut_refhas a KWDS.utI am trying to combine each ut_item's KWDS.de with the ut_ref's KWDS.deut_item-> KWDS.de | ut_ref->dehow can i make a select statement for that?
Can you explain more on this ? What do you mean "combine" ?Try posting some sample data and the result that you want. KH |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-28 : 08:14:08
|
something like this ?select combined = k.de + ut_reffrom CC c inner join KWDS k on c.ut_item = k.ut KH |
 |
|
|
georous
Starting Member
12 Posts |
Posted - 2007-01-28 : 08:46:40
|
| Table CC DataUT_ITEM : 00177456 UT_REF : 00175898Table KWDS DataUT : 00177456 DE: keyword1UT : 00175898 DE: keyword2i want a query that results like thiskeyword1 , keyword2This means that (1)ut_item has a keyword(2)ut_item references an ut_ref(3)which in turn has a keyword.The target is to "associate" a keyword to another based on the ut_item : ut_ref relationThank you for your support!! |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-28 : 09:07:09
|
[code]declare @CC table( ut_item varchar(10), ut_ref varchar(10))declare @KWDS table( ut varchar(10), de varchar(10))insert into @CC select '00177456', '00175898'insert into @KWDS select '00177456', 'keyword1'insert into @KWDS select '00175898', 'keyword2'select i.de, r.defrom @CC c inner join @KWDS i on c.ut_item = i.ut inner join @KWDS r on c.ut_ref = r.ut/*de de ---------- ---------- keyword1 keyword2*/[/code] KH |
 |
|
|
georous
Starting Member
12 Posts |
Posted - 2007-01-28 : 09:14:38
|
| SELECT * FROM (SELECT KWDS.UT , KWDS.DE FROM KWDS , CC WHERE CC.UT_ITEM = KWDS.UT) AS ITEM_T LEFT OUTER JOIN CC ON CC.UT_ITEM = ITEM_T.UT LEFT OUTER JOIN (SELECT KWDS1.UT , KWDS1.DE FROM KWDS AS KWDS1 , CC AS CC1 WHERE CC1.UT_REF = KWDS1.UT) AS ITEM_R ON CC.UT_REF = ITEM_R.UT;i did that query one hour ago (yes it took 1hour to finish!!!)but i wan not sure whether it was the correct logic to query.Thanx again for payin' attention on sunday noon to me :)Appreciate!! |
 |
|
|
|
|
|
|
|