0

its just simple where condition, but its working getting all data from the data table. Not considered the value false

select * from `api_auth` where `auth_key` = false; 
Kalidass
  • 424
  • 3
  • 18

1 Answers1

1

Here, the issue seems to be with the wrong usage of false in this statement as a Boolean datatype.

Since the datatype of auth_key column is text as you have mentioned as an answer to @ADyson, and you have used the Boolean false to compare the string datatype in the column, MySql is not populating the results as you require.

comparing you text column with a matching datatype(i.e., string) would fix the error.

i.e.,

select * from `api_auth` where `auth_key` = 'false';
Prashanth Benny
  • 1,523
  • 21
  • 33
  • whilst the solution will work, I dispute this statement: "wrong interpretation of false as a keyword or Boolean datatype by MySql compiler." MySQL is interpreting it correctly as the boolean literal FALSE (see https://dev.mysql.com/doc/refman/5.7/en/boolean-literals.html). But that boolean value is not equal to the text string "false", hence why it doesn't restrict the results as the OP wants. The real issue of course, is that OP is abusing the "text" data type to store boolean values and should use another more suitable data type. – ADyson Jan 05 '17 at 15:12
  • @ADyson you are right... I meant to say it that way... :O – Prashanth Benny Jan 05 '17 at 15:26
  • @ADyson i have edited the answer! hope it means the same :) . i am a bit bad in articulation! please forgive.... – Prashanth Benny Jan 05 '17 at 15:43
  • @ADyson thank you so much! you have been very helpful! – Prashanth Benny Jan 05 '17 at 15:46