Select stmt using Like

D

dpm1028

I have 2 tables in an db. Contacts is one with field LastName. The other is
Issues. The issues db has a free text field that stores lastname/lastname...
the field is called Owner. The objective is for multiple owners in an issue,
but not necessarily from the Contacts table.
I am trying to write a select statement that will allow me to compare the
Contacts.LastName with any Issues.Owner.
Select *
From Issues
Where Issues.Owner LIKE *[Contacts.lastname]* (except I cannot use this
format)
Any ideas would be appreciated.
 
K

Ken Snell

You can use a non-equi-join query (though it'll be slow with large amounts
of data):

Select *
From Issues INNER JOIN Contacts
ON Issues.Owner LIKE "*[Contacts.lastname]*";
 
J

John W. Vinson

I have 2 tables in an db. Contacts is one with field LastName. The other is
Issues. The issues db has a free text field that stores lastname/lastname...
the field is called Owner. The objective is for multiple owners in an issue,
but not necessarily from the Contacts table.
I am trying to write a select statement that will allow me to compare the
Contacts.LastName with any Issues.Owner.

Try

Select Issues.*
From Issues INNER JOIN Contacts
ON Issues.Owner LIKE "*" & [Contacts].[lastname] & "*"


This will give undesired results if there are LastName values such as "Wu" or
"Lo" or "Lee", since those text strings could appear in other parts of the
freeform text.
 
K

KARL DEWEY

Would it not be like this --
Select *
From Issues INNER JOIN Contacts
ON Issues.Owner LIKE "*" & [Contacts.lastname] & "*";

--
Build a little, test a little.


Ken Snell said:
You can use a non-equi-join query (though it'll be slow with large amounts
of data):

Select *
From Issues INNER JOIN Contacts
ON Issues.Owner LIKE "*[Contacts.lastname]*";

--

Ken Snell
http://www.accessmvp.com/KDSnell/



dpm1028 said:
I have 2 tables in an db. Contacts is one with field LastName. The other
is
Issues. The issues db has a free text field that stores
lastname/lastname...
the field is called Owner. The objective is for multiple owners in an
issue,
but not necessarily from the Contacts table.
I am trying to write a select statement that will allow me to compare the
Contacts.LastName with any Issues.Owner.
Select *
From Issues
Where Issues.Owner LIKE *[Contacts.lastname]* (except I cannot use this
format)
Any ideas would be appreciated.


.
 
K

Ken Snell

Yes, thanks for the catch, Karl.

--

Ken Snell
http://www.accessmvp.com/KDSnell/


KARL DEWEY said:
Would it not be like this --
Select *
From Issues INNER JOIN Contacts
ON Issues.Owner LIKE "*" & [Contacts.lastname] & "*";

--
Build a little, test a little.


Ken Snell said:
You can use a non-equi-join query (though it'll be slow with large
amounts
of data):

Select *
From Issues INNER JOIN Contacts
ON Issues.Owner LIKE "*[Contacts.lastname]*";

--

Ken Snell
http://www.accessmvp.com/KDSnell/



dpm1028 said:
I have 2 tables in an db. Contacts is one with field LastName. The
other
is
Issues. The issues db has a free text field that stores
lastname/lastname...
the field is called Owner. The objective is for multiple owners in an
issue,
but not necessarily from the Contacts table.
I am trying to write a select statement that will allow me to compare
the
Contacts.LastName with any Issues.Owner.
Select *
From Issues
Where Issues.Owner LIKE *[Contacts.lastname]* (except I cannot use this
format)
Any ideas would be appreciated.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top