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
 General SQL Server Forums
 New to SQL Server Programming
 Simple Squery

Author  Topic 

gurusamy.senthil
Yak Posting Veteran

65 Posts

Posted - 2007-02-20 : 06:09:08
Hello Everyone,

Can any one explain the following Select query which is using 1 ?

Select 1 from table1,table2 where table1.id = table2.id

In the above query 1 stands for ?

Thanks,
Senthil .G

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2007-02-20 : 06:28:50
The numeric value 1. The query will return the value 1 for however many rows the join produces. Try changing it to SELECT 'blah' ... etc to further illustrate the principal.

Mark
Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-02-20 : 22:25:35
Hello Mark,

In Senthil question, if Select 1 from table1,table2 where table1.id = table2.id found 5 records, what should be the result? 5 1's?

Thanks,
Ron
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-20 : 22:28:53
quote:
Originally posted by cwtriguns2002

Hello Mark,

In Senthil question, if Select 1 from table1,table2 where table1.id = table2.id found 5 records, what should be the result? 5 1's?

Thanks,
Ron


Yes. 5 rows of 1


KH

Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-02-20 : 22:40:56
Ok thanks.

Ron
Go to Top of Page
   

- Advertisement -