Difference between OR , AND with where in mysql -


i'm learning mysql

but felt confused after examples below :

select * `users` username = 'admin' or true; 

here returned rows in users table !

(username = 'admin' or true ) should true ? true

but in example :

select * `users` username = 'admin' , true; 

it returned 1 row (where username = 'admin')

but (username = 'admin' , true) should true !

so what's difference?

-- true 1   -- true rows username admin username = 'admin' 

now check truth table:

x  y | x , y | x or y ----------------------- f  f |    f    |   f f  t |    f    |   t t  f |    f    |   t t  t |    t    |   t 

https://en.wikipedia.org/wiki/boolean_algebra

if take

  • x where username = 'admin' ,
  • y where 1

you should understand results.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -