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 |
|
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2004-11-23 : 14:38:57
|
| Hi friendswhich one of the following is ideas/better1) select * from authors where authid='12'2) select * from authors having authid='12'I believe first one is faster but i noticed one of senior collegues using lot sql stmts like the 2nd one.Any ideasCheers |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-11-23 : 14:41:16
|
| select * from authors where authid='12'The second probably comes from access and is very poor.Should only use having with a group by and only for agregates.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
DustinMichaels
Constraint Violating Yak Guru
464 Posts |
Posted - 2004-11-23 : 14:42:34
|
| You only need to use having when your using a group by clause (for example, having COUNT(*) > 1). You should try to use the where clause whenever you can over the having clause.Dustin Michaels |
 |
|
|
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2004-11-23 : 14:43:58
|
| Thanks for quick replies nr and Dustin.I just wondered why our senior colleagues uses that way.Thanks once againCheers |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-11-23 : 14:52:02
|
quote: [i]but i noticed one of senior collegues using lot sql stmts like the 2nd one.
Not in SQL Server you didn't.That would throw an errorBrett8-) |
 |
|
|
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2004-11-23 : 14:53:50
|
| ha..ha.. u r right Brettwe use visual foxpro !!ThanksCheers |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-11-26 : 02:43:28
|
| "You should try to use the where clause whenever you can over the having clause"And SQL Server will convert HAVING into WHERE whenever IT can!Kristen |
 |
|
|
|
|
|