why we use 1=1 in sql query | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why we use 1=1 in sql query

please clarify me SELECT * FROM user WHERE userID=102 or 1=1 ; what does it mean 1=1

12th Sep 2016, 2:29 PM
Rishi Thakur
Rishi Thakur - avatar
6 Answers
+ 1
@rishi , if you don't use 1= 1 then it will take only first condition.
13th Sep 2016, 8:14 AM
sangamesh naikar
sangamesh naikar - avatar
0
it's true condition, if userid does not equal to 102 then it will take condition as true . and return all the values
12th Sep 2016, 2:51 PM
sangamesh naikar
sangamesh naikar - avatar
0
any disadvantage of this quey??
12th Sep 2016, 2:54 PM
Rishi Thakur
Rishi Thakur - avatar
0
what would happen when i do not use 1=1 ??
12th Sep 2016, 2:57 PM
Rishi Thakur
Rishi Thakur - avatar
0
so sangmesh u mean to say that 1=1 is just working as a validation conditiin
12th Sep 2016, 7:16 PM
Nitesh Yadav
Nitesh Yadav - avatar
0
@nitesh .. it's just true condition
13th Sep 2016, 8:13 AM
sangamesh naikar
sangamesh naikar - avatar