SELECT WHERE IN problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
winky3d
Forum Newbie
Posts: 9
Joined: Thu Apr 26, 2007 1:37 pm

SELECT WHERE IN problem

Post by winky3d »

see below please
Last edited by winky3d on Wed May 02, 2007 7:26 pm, edited 1 time in total.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

Can you post an example SQL query (no variables)? Also, use the [ syntax="sql"] [ /syntax] tags (without spaces after the opening brackets).
winky3d
Forum Newbie
Posts: 9
Joined: Thu Apr 26, 2007 1:37 pm

Post by winky3d »

Sorry, don't know what you meant by using [ syntax="sql"] [ /syntax] tags
Weirdan|Like it's done below in this post


Thx Weirdan.

Using mySQL 4.1

This returns the correct count:

Code: Select all

SELECT COUNT(*) FROM "._MY_TABLE." WHERE ts BETWEEN '2007-01-01 00:00:00' AND '2008-01-01 00:00:00' AND pcode IN ('aew', 'sdd')




This ignores the IN clause and returns all rows between the dates:

Code: Select all

SELECT email, l_name, state FROM "._MY_TABLE." WHERE ts BETWEEN '2007-01-01 00:00:00' AND '2008-01-01 00:00:00' AND pcode IN ('aew', 'sdd')

Suggestions?
winky3d
Forum Newbie
Posts: 9
Joined: Thu Apr 26, 2007 1:37 pm

solved

Post by winky3d »

The code works fine. I don't...

The sql was preceded with an if(...) that had a null variable.

Sorry for wasting your time... and mine, argh!
Post Reply