Hi all,
what is the output of select * from emp where null=null & select * from emp where 1=1?
Thanks
Sql query
5 Answers
Know the answer? Post it. Somebody with the same question will find it here.
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
Daniel Varghese14 reputationPosted Jun 12, 2010, 2:40 AM EDT
Both the select queries will return all the records from the emp table since the where conditions will always be true for all the records.
Thanks,
Daniel
Satyapriya NayakRank #47 · 31.5K reputationPosted Jun 12, 2010, 6:08 AM EDT
Thanks
Deepak Pandey71 reputationPosted Jun 12, 2010, 9:06 PM EDT
does not display any records from the emp table .
and ur second query i.e. "select * from emp where 1=1"
will display all records from the emp table since the where conditions will always be true for all the records.
Shambhu55 reputationPosted Aug 15, 2010, 10:40 AM EDT
if u will set ANSI_NULLS OFF and try this
set ansi_nulls off
select * from emp where null=null
It will give all records from the table
but if you will set ANSI_NULLS on and execute like
set ansi_nulls on
select * from emp where null=null
no record will be displayed.
and
select * from emp where 1=1 also will give all records.
Regards,
Shambhu
Kiran Nakhale5 reputationPosted Aug 15, 2010, 10:35 PM EDT
Hi,
First Query will result nothing and second query would return all values of table since 1=1 is true
Thanks,
Kiran