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 2000 Forums
 Transact-SQL (2000)
 comma seperated join on tables????

Author  Topic 

under2811
Constraint Violating Yak Guru

366 Posts

Posted - 2006-09-11 : 01:43:23
hello friends!!

I have Priority_tst table and product_tst table..

create table Priority_tst (id int,status varchar(10))

insert into Priority_tst (id,statu) values(1,'High')
insert into Priority_tst (id,status) values(2,'Low')
insert into Priority_tst (id,status) values(3,'Medium')

and

create table Product_tst (pid int,pnme varchar(5),statusid varchar(10))

insert into Product_tst (pid,pnme,statusid) values(1,'Sugar','1,2')
insert into Product_tst (pid,pnme,statusid) values(2,Milk,'2,3')

i want join with this two tables and return values in tearms of High , Low , Medium like

select M.pid,M.pnme,N.status from Product_tst M join Priority_tst N
on....... where M.pid = 1

output like

pid pnme status
1 Sugar High
1 Sugar Low


T.I.A

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-09-11 : 01:57:12
I think you need to normalize your data..

Check out this link to convert the CSV to Int..

http://www.sqlteam.com/item.asp?ItemID=11499

Chirag
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-11 : 02:33:39
Drop the statusid column from product_tst table and create a new table with two columns:

priority_tst table:
ProductID INT
PriorityID INT

DATA IN priority_tst table
1 1
1 2
2 2
2 3


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-11 : 12:29:31
Also read about Normalisation
http://www.datamodel.org/NormalizationRules.html


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -