select salary from dbo.Employee where 1==1 . -- What will this query return?
Hello everyone I have one query regarding to sql.
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
select salary from dbo.Employee where 1==1 . -- What will this query return?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh KumarRank #91 · 22.9K reputationPosted Dec 28, 2024, 11:36 AM EST
Hello Sourabh,
First of all == will not work,
In standard SQL, the equality operator is
=(not==). The query you wrote might not execute if the SQL dialect you're using does not support==for equality checks. The correct syntax would be:SELECT salary FROM dbo.Employee WHERE 1 = 1;The
WHERE 1 = 1condition always evaluates toTRUE, meaning it applies no filtering to the data.As a result, every row in the table satisfies the condition and is included in the result.
Naimish MakwanaRank #324 · 7.7K reputationPosted Dec 28, 2024, 7:43 AM EST
The query
SELECT salary FROM dbo.Employee WHERE 1=1;will return thesalarycolumn for all rows in theEmployeetable. The condition1=1is always true, so it doesn't filter out any rows. Essentially, this query retrieves the salary information for every employee in the table.Thanks
Sourabh DhimanRank #2,987 · 483 reputationPosted Dec 28, 2024, 12:37 PM EST
Thanks, Jignesh. This is my fault. I wrote
==in the query