#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    4
    Rep Power
    0

    WHERE clause not working


    I'm fairly convinced this is a bug...

    I have WAMP and am having issues with a single SQL query and a WHERE clause:

    SELECT `labnumber`, `enabled`, `pincode` FROM `labs` WHERE labnumber='1'

    Every time I run the query through the MySQL site it converts the condition on the WHERE clause to 1

    E.g.

    SELECT `labnumber`, `enabled`, `pincode` FROM `labs` WHERE 1

    I don't understand if one of my columns is incorrectly configured for operating with the WHERE clause, but it is a PITA right now... Any help would be greatly appreciated!
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,112
    Rep Power
    9398
    I'm 99% certain it's not a bug.

    What's the CREATE TABLE for the table and what is a sample of the data it's incorrectly returning?
  4. #3
  5. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    I run the query through the MySQL site
    What do you mean by this, what software are you using to run the query?
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    4
    Rep Power
    0

    PHPMyAdmin


    Originally Posted by E-Oreo
    What do you mean by this, what software are you using to run the query?
    Sorry I know I'm not 100% on the lingo and wasn't thinking... I use WAMP, and PHPMyAdmin 3.5.1 to manage my MySQL DB and test queries. I'm coding in PHP. I've run queries directly from PHPMyAdmin as well as echo'ed the queries from my PHP code and manually run them in PHPMyAdmin, same results...
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    4
    Rep Power
    0

    More Info


    Originally Posted by requinix
    I'm 99% certain it's not a bug.

    What's the CREATE TABLE for the table and what is a sample of the data it's incorrectly returning?
    I created the table through PHPMyAdmin
    It has 3 columns:
    labnumber - INT
    enabled - BOOL
    PIN - TEXT

    I run my query with WHERE labnumber=1 (the row values are 1, 2, and 3. there are only 3 rows in this table) It converts the WHERE to WHERE 1, and always returns all three rows.
  10. #6
  11. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    MySQL can't be removing a condition from the WHERE clause because it's not capable of doing that under any configuration. phpMyAdmin does modify queries sometimes, but only to rewrite the LIMIT clause; it wouldn't change a WHERE clause.

    What about the data requinix asked for? Depending on how your table is structured, MySQL might be enforcing the WHERE clause in an unexpected way.

    EDIT: disregard the second part, didn't see your second post

    Do a
    Code:
    SHOW CREATE TABLE `tablename`;
    Last edited by E-Oreo; June 25th, 2013 at 11:08 PM.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    4
    Rep Power
    0

    cannot run query


    I tried to run what you said, but PHPMYAdmin says "Missing value in the form!"

    Originally Posted by E-Oreo
    MySQL can't be removing a condition from the WHERE clause because it's not capable of doing that under any configuration. phpMyAdmin does modify queries sometimes, but only to rewrite the LIMIT clause; it wouldn't change a WHERE clause.

    What about the data requinix asked for? Depending on how your table is structured, MySQL might be enforcing the WHERE clause in an unexpected way.

    EDIT: disregard the second part, didn't see your second post

    Do a
    Code:
    SHOW CREATE TABLE `tablename`;

IMN logo majestic logo threadwatch logo seochat tools logo