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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Querying a Access DB with SQL

Author  Topic 

DavidMorgan
Starting Member

5 Posts

Posted - 2002-05-29 : 04:54:27
Hi,

I am using a Visual Basic front end that is hooked up to a Access Database (.MDB), I am using SQL statements to querry that database only. The simple queries that I have used work fine but now I am attempting to create a query that will search for a keyword in a field that has a whole string of words. What I have is a address field and a city field, I have the SQL query working fine for the search for the city, it is a extension saying "AND dep_city = 'Lincoln' "

The problem is that the address field could be filled with a string of words such as below:
36 Bishops Drive, Welton, West Side

I need the search to look for one word from that field, such as Welton, or even Bishops. I have been given a SQL statement that goes like this: "AND address like '%Welton%'" but this does not work although it should do in theory, at least on SQL Server, but not for Access?

Anyhelp you could give me would be much appreciated.

Thanks a lot, David




Edited by - DavidMorgan on 05/29/2002 08:19:46

joldham
Wiseass Yak Posting Master

300 Posts

Posted - 2002-05-29 : 07:54:08
David,

Please do not cross post.

http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=16275

If you have further questions, explain them in the topic you have already opened.

To answer this question, replace the = sign with the keyword like.

address like '%Welton%'


Edited by - joldham on 05/29/2002 07:55:10

Edited by - joldham on 05/29/2002 07:56:12

Edited by - joldham on 05/29/2002 07:56:39
Go to Top of Page

DavidMorgan
Starting Member

5 Posts

Posted - 2002-05-29 : 08:20:48
Thanks for the advice, but that was a type error on my part. I already use like, not =.

Thanks anyway

Go to Top of Page

joldham
Wiseass Yak Posting Master

300 Posts

Posted - 2002-05-29 : 12:36:41
David,

My mistake. If you are using an Access query, then you should replace the % character with *. If this doesn't work, post your query with some sample data and expected results and I will test it.

Jeremy

Go to Top of Page

DavidMorgan
Starting Member

5 Posts

Posted - 2002-05-29 : 12:40:57
Thats wonderful, thanks a lot, it worked.

David

Go to Top of Page
   

- Advertisement -