SQL Query "Like" clause 
Author Message
 SQL Query "Like" clause

Hi,

I am trying to throw a SQL select command at a jet & SQL server database. I
am trying to use a like clause to find records containing some of the info
in a string I pass. I cannot seem to find a where clause that will do this.

Where name LIKE 'Nigel' return nothing even if " Nigel1, Nigel 2, Nigel
Williams" is in the requested table.

Does anyone know the solution here, MSDN does not!

Regards,

 Nigel Williams.



Sat, 10 Aug 2002 03:00:00 GMT  
 SQL Query "Like" clause
You need to use the wildcard % so the SQL would be
... WHERE name LIKE 'Nigel%'

That will pick up anything starting with Nigel.

... WHERE name LIKE '%Nigel%'

will pick up the row if Nigel is anywhere in the name field.

Hope this helps

Derek.


Quote:

> Hi,

> I am trying to throw a SQL select command at a jet & SQL server database. I
> am trying to use a like clause to find records containing some of the info
> in a string I pass. I cannot seem to find a where clause that will do this.

> Where name LIKE 'Nigel' return nothing even if " Nigel1, Nigel 2, Nigel
> Williams" is in the requested table.

> Does anyone know the solution here, MSDN does not!

> Regards,

>  Nigel Williams.



Sat, 10 Aug 2002 03:00:00 GMT  
 SQL Query "Like" clause
If going native JET and/or DAO, use the wildcare '*'.

If going through ODBC or OLE-DB, use the wildcare '%'

... LIKE 'Nigel*'      or  .... LIKE 'Nigel%'

HTH

--
Patrick Logan, MCSD
Senior Technical Development Advisor
McKessonHBOC -- Extended Care Solutions Group
(417) 874-4000 ext. 4424



Sat, 10 Aug 2002 03:00:00 GMT  
 SQL Query "Like" clause

I think you need to wildcard it:

LIKE '*Nigel*'  

There are some changes going on with wildcards so the syntax may be:

LIKE '%Nigel%'   in your case.

Al


Quote:

>Hi,

>I am trying to throw a SQL select command at a jet & SQL server database. I
>am trying to use a like clause to find records containing some of the info
>in a string I pass. I cannot seem to find a where clause that will do this.

>Where name LIKE 'Nigel' return nothing even if " Nigel1, Nigel 2, Nigel
>Williams" is in the requested table.

>Does anyone know the solution here, MSDN does not!

>Regards,



Wed, 14 Aug 2002 03:00:00 GMT  
 SQL Query "Like" clause
What does LIKE '%Nigel%'  do...?

And how is it different from LIKE '*Nigel*' this is the one I use in Memo field
searches..

George

Quote:

> I think you need to wildcard it:

> LIKE '*Nigel*'

> There are some changes going on with wildcards so the syntax may be:

> LIKE '%Nigel%'   in your case.

> Al



> >Hi,

> >I am trying to throw a SQL select command at a jet & SQL server database. I
> >am trying to use a like clause to find records containing some of the info
> >in a string I pass. I cannot seem to find a where clause that will do this.

> >Where name LIKE 'Nigel' return nothing even if " Nigel1, Nigel 2, Nigel
> >Williams" is in the requested table.

> >Does anyone know the solution here, MSDN does not!

> >Regards,



Wed, 14 Aug 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Implementing "CONNECT BY" SQL clause

2. "~" in Field Name and SQL QUERY

3. "Inner Join" query with "Where" clause

4. "Where clause" question

5. ADO "syntax error in FROM clause"

6. ""Declare" query

7. *"*-.,._,.-*"* I"LL TRADE VISUAL C++ FOR VBASIC *"*-.,_,.-*"*

8. GetObject("","InternetExplorer.Application") fails in Excel VBA

9. SysCmd 603, "path","path"

10. Disabling "BACK"/"FORWARD" buttons

11. Loop print "VARIABLE", "VARIABLE"

12. DLL or something like "#"#ยค#"!"#

 

 
Powered by phpBB® Forum Software