Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

rhesa (5696)

  (email not shown publicly)

Journal of rhesa (5696)

Thursday March 29, 2007
09:01 PM

Two small gripes about MySQL

[ #32839 ]
  1. You can use an aliased column in the GROUP BY clause, but not in the WHERE clause:

    SELECT func(foo) as alias FROM baz GROUP BY alias

    works, but

    SELECT func(foo) as alias FROM baz WHERE alias='quux'  (*)

    doesn't. You have to write

    SELECT func(foo) as alias FROM baz WHERE func(foo)='quux'

  2. Modifying a column: which phrase will do what I want? ALTER COLUMN, CHANGE COLUMN, or MODIFY COLUMN? I can never remember and have to look them up.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I believe your example can be written thusly though:

    SELECT func(foo) as alias FROM baz HAVING alias='quux'

    • Which is still horrible because HAVING operates after a GROUP BY operation ... in fact I wonder if HAVING without a GROUP BY would give errors with other databases (SQLite 2.8.17 gives an error for example)