Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 What will be the output of the query

Author  Topic 

Swati Jain
Posting Yak Master

139 Posts

Posted - 2007-04-17 : 06:06:26
Hello all,
SELECT * FROM table WHERE 1=0
what this clause exactly means WHERE 1=0

what type of output i will get.Plz make me understand

Swati

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-17 : 06:27:46
Did you try it?
What result did you get? What happened in Query Analyzer or SSMS?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-17 : 07:12:17
What will you get when where condition is not satisfied?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Swati Jain
Posting Yak Master

139 Posts

Posted - 2007-04-17 : 07:39:13
Hi Peso,
I tried it in query analyzer but i got no records satisfying query
what does such type of query mean?
Select * from table where 1=0
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-17 : 07:41:23
Yes you did!
You got all records who fulfilled the query filtering.

Please think!

What will you get when you writ

1) select * from table where lastname = 'smith'
2) select * from table where id = 1
3) select * from table where 1 = 0




Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-17 : 07:46:24
This query as you posted it, has no practical usage what-so-ever. However, below query is used to create a copy of table without copying its data:

SELECT * INTO #temp
from SomeTable
Where 1=0


Not a good practice, though!

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-17 : 11:41:05
quote:
Originally posted by Swati Jain

Hello all,
SELECT * FROM table WHERE 1=0
what this clause exactly means WHERE 1=0

what type of output i will get.Plz make me understand

Swati


It is used to get empty resultset
Same as

Select top 0 * from table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

ACushen
Starting Member

29 Posts

Posted - 2007-04-26 : 13:56:18
Hmmm. This sounds suspiciously like a homework question... ;-)

-Andrew
Go to Top of Page
   

- Advertisement -