Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unexpected text at end of SQL query?

Status
Not open for further replies.

JohnnyT

Programmer
Jul 18, 2001
167
GB
Hi

I'm running the following script query on my database but keep getting the error:
Unexpected text at end of SQL query: '='

The query is:
"SELECT PROG_NO FROM pallet_formats WHERE FIELD87 = 5;";

I get the same error when I run:
"SELECT PROG_NO FROM pallet_formats WHERE FIELD87 LIKE '5';";

It also doesn't make a difference if I include the apostrophe's around my search term or not. ie. LIKE 5 or LIKE '5' give me...
Unexpected text at end of SQL query: 'LIKE'

Anyone any ideas? Is it possible that the LIKE command isn't used on Access. Yesterday I had trouble with the LIMIT command and found out you had to use TOP instead?

Thanks for any help you can give me.

Cheers

JT :)

I don't make mistakes, I'm merely beta-testing life.
 
Remove the semicolons.

If you use Like you should be using a wildcard somewhere.
Like '5*'
(This assumes that field87 is a text field. You cannot use wildcards with a number field)
 
Lupins

I just changed the query to...
"SELECT PROG_NO FROM pallet_formats WHERE FIELD87 LIKE '*5'";

And I still got:
Unexpected text at end of SQL query: 'LIKE'

Any ideas? FIELD87 is a text field.

Cheers

JT

I don't make mistakes, I'm merely beta-testing life.
 
Lupins...

Sussed it.

The command I was passing was actually a concantenated string ie.
SearchString = "select blah blah";
SeachString = SearchString + " where field87 like '05'";
SearchString = SearchString + "and field88 like... etc etc

The problem was I had left out the space on the second set of likes so the compiler saw it as "where field87 like '05'and field88 etc etc

Many thanks for your help mate.

Cheers

JT :)

I don't make mistakes, I'm merely beta-testing life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top