By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,894 Members | 1,942 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,894 IT Pros & Developers. It's quick & easy.

SELECT ... WHERE a.column1 LIKE b.column2 - is it possible?

P: n/a
Hello I need to select records from table1 where column1 is a part of
column2 in table2, but with this query I can't obtain the desired result:

SELECT * from table1 a, table2 b where b.column2 LIKE a.column1
SELECT * from table1 a, table2 b where b.column2 LIKE '*' + a.column1 + '*'

If I try to this, it works:

SELECT * from table1 where a.column1 LIKE '*sometext*'

My database is access, but it must work also in ms-sql server
Anyone has ideas?
Thank you
Alex.
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Alex" <al**@unsampdorianosoftmasters.net> wrote in message
news:bm**********@newsreader.mailgate.org...
Hello I need to select records from table1 where column1 is a part of
column2 in table2, but with this query I can't obtain the desired result:

SELECT * from table1 a, table2 b where b.column2 LIKE a.column1
SELECT * from table1 a, table2 b where b.column2 LIKE '*' + a.column1 + '*'
If I try to this, it works:

SELECT * from table1 where a.column1 LIKE '*sometext*'

My database is access, but it must work also in ms-sql server


I think your second one would work if you used & instead of +. I don't
know if SQL Server supports these kinds of joins or not. If it does you
would stay with the + signs and substitute % for *. There is no one syntax
that will work in both without modification because the two systems have
many differences in SQL syntax.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.