![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Here is what we can do with IN: SELECT * FROM language WHERE langkey IN ( SELECT acct_desc || '-' FROM dbo.product WHERE acct_code LIKE 'WSDOM%'); but what if you dont want exact matching like IN gives and want to do a LIKE... what can you do.. Here is what I want: SELECT * FROM language WHERE langkey INLIKE ( SELECT acct_desc || '-%' FROM dbo.product WHERE acct_code LIKE 'WSDOM%'); |
#3
| |||
| |||
|
|
For future questions, you are likely to get more help if you provide table definitions and some sample data. |
|
select l.* from language l join product p * * on substr(l.langkey,1,length(p.acct_desc)) = p.acct_desc where p.acct_code like 'WSDOM%'; |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
CREATE TABLE Patterns (search_pattern VARCHAR(25) NOT NULL); INSERT INTO Patterns VALUES ('AB%'), (BC%'), etc. SELECT S.some_column, P.pattern, .. FROM Source AS S, Patterns AS P WHERE S.some_column LIKE P.pattern; You can also use a table constructor directly in the query. (SELECT pattern FROM (VALUES ('AB%'), (BC%'), etc.) AS X(pattern)) AS P |

#6
| |||
| |||
|
|
Here is what we can do with IN: SELECT * FROM language WHERE langkey IN ( SELECT acct_desc || '-' FROM dbo.product WHERE acct_code LIKE 'WSDOM%'); but what if you dont want exact matching like IN gives and want to do a LIKE... what can you do.. Here is what I want: SELECT * FROM language WHERE langkey INLIKE ( SELECT acct_desc || '-%' FROM dbo.product WHERE acct_code LIKE 'WSDOM%'); |
#7
| |||
| |||
|
|
Although it won't help the OP because he/she |

|
is using SQL Server (as far as I can tell) |
|
and last time I checked, SQL Server did not support the row/table constructor using the VALUES clause Regards Thomas |
#8
| |||
| |||
|
|
Although it won't help the OP because he/she is using SQL Server (as far as I can tell) and last time I checked, SQL Server did not support the row/table constructor using the VALUES clause |
#9
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |