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.
| Author |
Topic |
|
aylin_sk
Starting Member
25 Posts |
Posted - 2005-01-25 : 03:45:19
|
| Why do we use "1" in sql?Select 1 from Table |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-01-25 : 03:48:40
|
quote: Originally posted by aylin_sk Why do we use "1" in sql?Select 1 from Table
what do you mean?your query will return n-number of 1's depending on the number of rows returned --------------------keeping it simple... |
 |
|
|
aylin_sk
Starting Member
25 Posts |
Posted - 2005-01-25 : 03:54:26
|
| Does it mean that selecting 1 means from a table returning number of rows?? |
 |
|
|
guidomarcel
Starting Member
5 Posts |
Posted - 2005-01-25 : 04:14:00
|
| If you just want to do an existence check and you are not interested on any field values it is more performant to select a constant (1 or "1", "2", etc.). RegardsGuidoMArcelThe free SQL Code Formatter on www.sqlinform.com |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-01-25 : 04:43:23
|
quote: Originally posted by aylin_sk Does it mean that selecting 1 means from a table returning number of rows??
actually not exactly, what i mean is that if you do a select 1 from table1you're returning the value 1 n-number of times, let say you have 10 rows in table1, then you'll get 10 rows with one column having the value 1.to provide you with the number of rows:a. issue a select @@rowcount right after the select statementb. select count(*) from table1you might want to rephrase your question, is that what you were asking?--------------------keeping it simple... |
 |
|
|
aylin_sk
Starting Member
25 Posts |
Posted - 2005-01-26 : 05:00:42
|
| Thanks a lot.. |
 |
|
|
|
|
|