HELP / HELP / syntax SQL / 'LIKE' clause 
Author Message
 HELP / HELP / syntax SQL / 'LIKE' clause

Could anybody kindly tell me the proper format for the following:

Qry = "SELECT * FROM table1 WHERE field1 LIKE "ABC%""

I do not understand how the specify the LIKE expression "ABC%" within
the Qry assignment statement. SQL syntax says ABC% must be in quotes
the statement above chokes when it finds the first " in front of ABC%
What combination of characters must I use to make this LIKE expression
work?

Thanks so much for any help, Greg Hedberg



Sat, 05 Dec 1998 03:00:00 GMT  
 HELP / HELP / syntax SQL / 'LIKE' clause

Quote:

> Could anybody kindly tell me the proper format for the following:

> Qry = "SELECT * FROM table1 WHERE field1 LIKE "ABC%""

Use single quotes as in:

Qry = "SELECT * FROM table1 WHERE field1 LIKE 'ABC%'"



Sat, 05 Dec 1998 03:00:00 GMT  
 HELP / HELP / syntax SQL / 'LIKE' clause

Quote:

>Could anybody kindly tell me the proper format for the following:
>Qry = "SELECT * FROM table1 WHERE field1 LIKE "ABC%""
>I do not understand how the specify the LIKE expression "ABC%" within
>the Qry assignment statement. SQL syntax says ABC% must be in quotes
>the statement above chokes when it finds the first " in front of ABC%
>What combination of characters must I use to make this LIKE expression
>work?

Greg, You need to place single quotes around the ABC%.  
Qry = "SELECT * FROM table1 WHERE field1 LIKE 'ABC%'"  should do the
trick.

Ed
********************************************************
**  Southern Indiana Bass Fishing / Outdoor Software  **
**    HTTP://www.evansville.net/~dlion/mypage.htm    **
********************************************************



Sun, 06 Dec 1998 03:00:00 GMT  
 HELP / HELP / syntax SQL / 'LIKE' clause

Quote:

>Could anybody kindly tell me the proper format for the following:
>Qry = "SELECT * FROM table1 WHERE field1 LIKE "ABC%""
>I do not understand how the specify the LIKE expression "ABC%" within
>the Qry assignment statement. SQL syntax says ABC% must be in quotes
>the statement above chokes when it finds the first " in front of ABC%
>What combination of characters must I use to make this LIKE expression
>work?
>Thanks so much for any help, Greg Hedberg


The correct format is:

Qry = "SELECT * FROM table1 WHERE field1 LIKE 'ABC*' "

ABC is enclosed in single quotes.
Jerry Helms
Intelligent Information Systems



Sun, 06 Dec 1998 03:00:00 GMT  
 HELP / HELP / syntax SQL / 'LIKE' clause

Quote:

> Could anybody kindly tell me the proper format for the following:

> Qry = "SELECT * FROM table1 WHERE field1 LIKE "ABC%""

> I do not understand how the specify the LIKE expression "ABC%" within
> the Qry assignment statement. SQL syntax says ABC% must be in quotes
> the statement above chokes when it finds the first " in front of ABC%
> What combination of characters must I use to make this LIKE expression
> work?

> Thanks so much for any help, Greg Hedberg


Use single quotes for the LIKE criteria:

Qry = "SELECT * FROM table1 WHERE field1 LIKE 'ABC%'"



Sun, 06 Dec 1998 03:00:00 GMT  
 HELP / HELP / syntax SQL / 'LIKE' clause

Hi - I need help on "extracting" data from a table into a file.  I have
the table with the data entered using Data Management.  I would like to
put all the information onto a file so I can read it into my program.

        Please, if you know how to do this, let me know - any
suggestions will be greatly appreciated.

        Thank you very much,

                        Cindy



Sun, 06 Dec 1998 03:00:00 GMT  
 HELP / HELP / syntax SQL / 'LIKE' clause

Quote:

> Could anybody kindly tell me the proper format for the following:

> Qry = "SELECT * FROM table1 WHERE field1 LIKE "ABC%""

> I do not understand how the specify the LIKE expression "ABC%" within
> the Qry assignment statement. SQL syntax says ABC% must be in quotes
> the statement above chokes when it finds the first " in front of ABC%
> What combination of characters must I use to make this LIKE expression
> work?

> Thanks so much for any help, Greg Hedberg


You'll probably need to use the single quote ( ' ) character.  Try this:

szMyQuery = "SELECT * FROM table1 WHERE field1 LIKE 'ABC%' "

Best of luck,



Mon, 07 Dec 1998 03:00:00 GMT  
 HELP / HELP / syntax SQL / 'LIKE' clause

I have read all of the answers to your question and would like to say that I
agree with the responses.  I would just like to point out the minor
differences and why there are differences.

There were two basic answers:

1. Qry = "SELECT * FROM table1 WHERE field1 LIKE 'ABC%' "

2. Qry = "SELECT * FROM table1 WHERE field1 LIKE 'ABC*' "

For those of you that have not run into this situation,  ACCESS uses the (*)
star symbol for the wild card; however, SQL Server uses the (%) percent sign
for the wild card.

It can be a problem when trying to "scale up" from ACCESS to SQL Server.

Have a nice day!

Rob

Quote:

>Could anybody kindly tell me the proper format for the following:

>Qry = "SELECT * FROM table1 WHERE field1 LIKE "ABC%""

>I do not understand how the specify the LIKE expression "ABC%" within
>the Qry assignment statement. SQL syntax says ABC% must be in quotes
>the statement above chokes when it finds the first " in front of ABC%
>What combination of characters must I use to make this LIKE expression
>work?

>Thanks so much for any help, Greg Hedberg




Tue, 08 Dec 1998 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Problem with SQL 'Like' Clause

2. Problems with SQL 'Like' clause

3. Help!!! for SQL syntax: LIKE clause

4. hELP!!! FOR SQL SYNTAX: LIKE CLAUSE

5. help on 'if...then' syntax

6. '|' Character in SQL Syntax

7. '|' Character in SQL Syntax

8. SQL Where Clause [ ex: where column in ('123','456','789') ]

9. Need help with SQL query 'AND'ing a field against a constant

10. FROM clause in VB5's SQL

11. **************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Help me !!!!!!!!!!!!!!!!!!!!!!!!'''''''''''''''''''''''*************

12. VB Newbie needs HELP with API's and Syntax

 

 
Powered by phpBB® Forum Software