-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On September 10, 2002 23:25, Zak Greant wrote: > On September 10, 2002 22:32, Paul DuBois wrote: > ... > > > You can't refer to aliases in WHERE clauses. Aliases refer to columns > > that have been selected, WHERE clauses determine which columns should > > be selected. In essence, WHERE refers to "input" columns, which occurs > > earlier than the aliases (which refer to "output" columns). > > Hi Nicholas, > > You may be able to get the effect that you desire using user variables. > (see http://www.mysql.com/doc/en/Variables.html for details) > > The following query using user variables *might* work for you :) > > SELECT > i.id image_id, > @photo_id := ifnull(i.photographer,"6") photo_id, > @owner_id := ifnull(i.owner,"6") owner_id, > concat(cp1.fname,' ',cp1.lname) photo_id, > concat(cp2.fname,' ',cp2.lname) owner_name, > FROM > image i, > common.persons cp1, > common.persons cp2 > WHERE > i.id='8200' > AND @photo_id=cp1.id > AND @owner_id=cp2.id;
Before anyone goes off and tries this, let me assure that I am completely wrong here. :) As Paul kindly pointed out off-list, the variables in this query will only be set when conditions in the WHERE clause are met. Now, given that the WHERE clause is attempting to use variables that can only be set when it is successful... :) Embarrassedly Yours, - -- Zak Greant <[EMAIL PROTECTED]> MySQL Community Advocate Feed the Dolphin! Order MySQL support from the MySQL developers at https://order.mysql.com/?ref=mzgr "Gosh, Batman! The nobility of the almost-human porpoise." --Robin -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9gV1tb6QONwsK8bIRAuj9AJ9fqYsa/ff7FTXeoYlsdZsXgg6FugCeIjpb oc/oXLSvD/PnUpY9y0L8eKE= =7n14 -----END PGP SIGNATURE----- --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php