Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I have a table with 2 columns:Col1 Col2stat1,stat2 AV,ADstat3 TDI need to build a query like this:SELECT *FROM table3WHERE stat1=AV and stat2=AD and stat3=TDHow 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 Col2stat1,stat2 AV,ADstat3 TD
which value is for which column ?KH
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 @table3select 'stat1,stat2', 'AV,AD' union allselect 'stat3', 'TD'SELECT *FROM @table3WHERE ',' + col1 + ',' like '%,stat1,%' and ',' + col2 + ',' like '%,AV,%' AND ',' + col1 + ',' like '%,stat2,%' and ',' + col2 + ',' like '%,AD,%'