MySQL Forums
Forum List  »  Newbie

Re: Expressions in queries
Posted by: chris hearn
Date: April 22, 2005 11:08AM

mjac wrote:
> I asked this last night on quakenet and didn't get
> an answer (as par usual).
>
> How can I do something similar to: SELECT
> (complicated expression) as `exp` WHERE
> `field`<`exp` and `anotherfield`>`exp`.
>
> I want to use exp more than once, but I don't want
> it to be calculated many times. writing the full
> expression for each use of exp is labourous and
> slow. Any ideas?
>
> Thanks

a) What language are you using?
b) SELECT (complicated expression) doesn't make any sense to me, as this part should just be the column names. If you expression is supposed to produce column names, then you should create the string beforehand, then just add it into your query string.

in php you might do something like
$sql="SELECT ".$mycomplexstring."WHERE...blah=bah etc";

Chris

Options: ReplyQuote


Subject
Written By
Posted
April 21, 2005 04:08PM
April 22, 2005 08:55AM
Re: Expressions in queries
April 22, 2005 11:08AM
April 23, 2005 01:15PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.