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 |
|
Gervahlt
Starting Member
3 Posts |
Posted - 2010-01-11 : 02:33:51
|
| Okay, my statement is quite a bit more complicated that this, but I'm going to focus on the piece that's kicking me in the stomach right now. I need some way to pull fields from a table where a text column contains any of a list of items in another table.So, if the below would work (which it doesn't), it would be ideal:Select a.column1, a.column2From Table1 aWhere a.column2 LIKE IN('%'+(Select b.column1 From Table2 b)+'%')Thanks in advance for any help offered! |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-01-11 : 03:34:37
|
| Do you have any relation between Table1 and Table2?Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2010-01-11 : 03:39:41
|
HiTry thisSELECT C.COLUMN1, C.COLUMN2FROM TABLE1 CWHERE EXISTS (SELECT *FROM TABLE2 NWHERE C.COLUMN2 LIKE N.COLUMN1 + '%') -------------------------[R][A][J] |
 |
|
|
Gervahlt
Starting Member
3 Posts |
Posted - 2010-01-11 : 03:40:14
|
| Not really. In this case, the text field contains a listing of course titles that, unfortunately weren't uniform in creation, so they don't conform to a particular format. The criteria field consists of a list of required courses.The only relation is that, for the records I'm looking for, somewhere within the course title will be the text from the criteria...but it might be anywhere in the title. Right now that list is fairly small, but I'm trying to future-proof this a bit since I won't always be around and make it so their list of required courses can be added to, or changed, later down the road. |
 |
|
|
Gervahlt
Starting Member
3 Posts |
Posted - 2010-01-11 : 03:54:44
|
| rajdaksha - your solution worked like a charm! Thank you! |
 |
|
|
|
|
|
|
|