Click to See Complete Forum and Search --> : Does this make sense??


WillBoss
07-19-2006, 12:18 PM
Hi

I am new to SQL and have a problem with a Select statement that I have in a small online app that I am trying to write. This is the statement

select email_address from subscriber_list where zip_code in ('45675','23456','44444','73653');

This is the error that is being displayed:

There was a problem sending the email. #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Thanks
Will

dthurman1432
07-19-2006, 01:31 PM
You need to take out the single quotes around the zips

Should be this:

select email_address from subscriber_list where zip_code in (45675, 23456, 44444, 73653);

WillBoss
07-19-2006, 02:38 PM
Did that already but I did it again and I am getting the same error. I typed in my query in the MySql query browser and got back the results with no problems. Dont know whats up! :confused:

dthurman1432
07-19-2006, 03:58 PM
Try this. Since you're using it by zip code it would be safe to use:

select email_address from subscriber_list where zip_code LIKE '%45675%' OR zip_code LIKE '%23456%' OR zip_code LIKE '%44444%' OR zip_code LIKE '%73653%';

WillBoss
07-19-2006, 04:46 PM
Still no joy.

The code in my app reads like this:
sQuery = "select * from subscriber_list having zip_code in " + "(" + loopzip_code + ")" + ";"

Like I said the code works in the MySql query browser. It must be something in Visual Studido. I actually display the sql statement to the screen to see if it looks ok and it does. :confused:

dthurman1432
07-19-2006, 05:38 PM
dl the sql 4.1 and replace the files. This will fix the problem. The newer sql uses a different syntax.

WillBoss
07-21-2006, 09:36 AM
Err..... Sorted the problem out. There was a problem with the syntax but unfortunately it wasnt with that line of code. I had another line that I thought I had commented out that was performing another query and it was that one which was causing the problems. Ahaaaa....Stupid Me.

dthurman1432
07-21-2006, 10:19 AM
nice