ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cannot Get SQL Query to Work with "LIKE" (https://www.excelbanter.com/excel-programming/354314-cannot-get-sql-query-work-like.html)

Chaplain Doug

Cannot Get SQL Query to Work with "LIKE"
 
Excel 2003. I have a module that grabs some data from an SQL database using
an ADODB connection. If I use the following in the SQL query, it returns no
data:

(WHERE INVOICENUMBER LIKE 'MS*')

However, if I use the following, I get all the data I expect:

(WHERE INVOICENUMBER='MS' AND INVOICENUMBER<='MS9999999999999')

What am I doing wrong? How may I properly use the LIKE phrase? Thanks for
any help.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org

Jim F

Cannot Get SQL Query to Work with "LIKE"
 
Try using a % symbol instead of a * symbol

I bleieve * symbol is used with MS Access and % is used with SQL

"Chaplain Doug" wrote:

Excel 2003. I have a module that grabs some data from an SQL database using
an ADODB connection. If I use the following in the SQL query, it returns no
data:

(WHERE INVOICENUMBER LIKE 'MS*')

However, if I use the following, I get all the data I expect:

(WHERE INVOICENUMBER='MS' AND INVOICENUMBER<='MS9999999999999')

What am I doing wrong? How may I properly use the LIKE phrase? Thanks for
any help.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org


Terry Aney

Cannot Get SQL Query to Work with "LIKE"
 
You could try LIKE 'MS%', the like clause in SQL uses % instead of * but I
would have expected ADO to do the conversion for you.

"Chaplain Doug" wrote in message
...
Excel 2003. I have a module that grabs some data from an SQL database
using
an ADODB connection. If I use the following in the SQL query, it returns
no
data:

(WHERE INVOICENUMBER LIKE 'MS*')

However, if I use the following, I get all the data I expect:

(WHERE INVOICENUMBER='MS' AND INVOICENUMBER<='MS9999999999999')

What am I doing wrong? How may I properly use the LIKE phrase? Thanks
for
any help.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org




Chaplain Doug

Cannot Get SQL Query to Work with "LIKE"
 
Thank you both for the help. God bless.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org


"Terry Aney" wrote:

You could try LIKE 'MS%', the like clause in SQL uses % instead of * but I
would have expected ADO to do the conversion for you.

"Chaplain Doug" wrote in message
...
Excel 2003. I have a module that grabs some data from an SQL database
using
an ADODB connection. If I use the following in the SQL query, it returns
no
data:

(WHERE INVOICENUMBER LIKE 'MS*')

However, if I use the following, I get all the data I expect:

(WHERE INVOICENUMBER='MS' AND INVOICENUMBER<='MS9999999999999')

What am I doing wrong? How may I properly use the LIKE phrase? Thanks
for
any help.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org






All times are GMT +1. The time now is 07:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com