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
 SQL Server Development (2000)
 query build help

Author  Topic 

sardinka
Posting Yak Master

142 Posts

Posted - 2007-04-24 : 15:51:07
I have a table with 2 columns:
Col1 Col2
stat1,stat2 AV,AD
stat3 TD
I need to build a query like this:
SELECT *
FROM table3
WHERE stat1=AV and stat2=AD and stat3=TD
How do I do this?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-24 : 18:48:22
quote:
I have a table with 2 columns:
Col1 Col2
stat1,stat2 AV,AD
stat3 TD

which value is for which column ?


KH

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-25 : 00:56:51
You mean something like this?
declare @table3 table (Col1 varchar(200), Col2 varchar(200))

insert @table3
select 'stat1,stat2', 'AV,AD' union all
select 'stat3', 'TD'


SELECT *
FROM @table3
WHERE ',' + col1 + ',' like '%,stat1,%' and ',' + col2 + ',' like '%,AV,%'
AND ',' + col1 + ',' like '%,stat2,%' and ',' + col2 + ',' like '%,AD,%'


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -