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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SELECT Help

Author  Topic 

georous
Starting Member

12 Posts

Posted - 2007-01-28 : 07:56:09
Hi! my db schema is the following

Table CC
ut_item ,ut_ref

Table KWDS
ut , de

Table KWDS_PLUS
ut ,id

Table UT_2_CONSIDER
ut

Each CC.ut_item and CC.ut_ref
has a KWDS.ut
I am trying to combine each ut_item's KWDS.de with the ut_ref's KWDS.de

ut_item-> KWDS.de | ut_ref->de
how can i make a select statement for that?

I Hope i was clear enough
Thank you!

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-28 : 08:07:17
quote:
Each CC.ut_item and CC.ut_ref
has a KWDS.ut
I am trying to combine each ut_item's KWDS.de with the ut_ref's KWDS.de

ut_item-> KWDS.de | ut_ref->de
how 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

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-28 : 08:14:08
something like this ?

select combined = k.de + ut_ref
from CC c inner join KWDS k
on c.ut_item = k.ut



KH

Go to Top of Page

georous
Starting Member

12 Posts

Posted - 2007-01-28 : 08:46:40
Table CC Data
UT_ITEM : 00177456 UT_REF : 00175898

Table KWDS Data
UT : 00177456 DE: keyword1
UT : 00175898 DE: keyword2

i want a query that results like this
keyword1 , keyword2
This 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 relation

Thank you for your support!!
Go to Top of Page

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.de
from @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

Go to Top of Page

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!!
Go to Top of Page
   

- Advertisement -