Shadowing Posted July 11, 2012 Share Posted July 11, 2012 Hey guys I dont really do a ton of sql statements in mysql but i did one today and the results puzzled me SELECT id,activation FROM users WHERE activation = 1 Quote Link to comment Share on other sites More sharing options...
Shadowing Posted July 11, 2012 Author Share Posted July 11, 2012 apparently if i dont do '1' it seraches for any 1's that exist geez didnt even know this Quote Link to comment Share on other sites More sharing options...
requinix Posted July 11, 2012 Share Posted July 11, 2012 MySQL is converting the string in the column to a number to match the 1 in your query. Means it ignores leading zeros and stops at the first invalid character (such as a letter). Use quotes so both the '1' and the column are the same data type. SELECT id,activation FROM users WHERE activation = '1' Quote Link to comment Share on other sites More sharing options...
Shadowing Posted July 11, 2012 Author Share Posted July 11, 2012 Oh thanks alot requinix had no idea it did that makes total sense though Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.