Matches in a database.

Corey Edwards tensai at zmonkey.org
Tue Jun 28 16:00:20 MDT 2005


On Tue, 2005-06-28 at 15:25 -0600, Matthew Walker wrote:
> Hmmm. I need to learn to use HAVING. I'm self taught, and have always
> just used WHERE. Thanks for showing us how to do this.

There's a difference although there's some overlap. WHERE operates only
on single rows and occurs before GROUP BY operations. HAVING takes
effect after GROUP BY and can thus work on aggregates. So you couldn't
say "WHERE COUNT(col) > 3" but you could use a HAVING. Most WHERE
clauses can move into a HAVING, but I'm sure it's much faster to do
table joins before GROUP functions and databases may not optimize them
the same way.

Corey

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://plug.org/pipermail/plug/attachments/20050628/2eaf8260/attachment.bin 


More information about the PLUG mailing list