Hi to all.
Is it possible to use mathematical operations and "extend" the
selected resultset with additional/virtual "fields?
Example:
SELECT *, (product_price * count_product) as sum_price FROM
shoppingcart
> Hi to all.
> Is it possible to use mathematical operations and "extend" the
> selected resultset with additional/virtual "fields?
> Example:
> SELECT *, (product_price * count_product) as sum_price FROM
> shoppingcart
> Additional Information: > I forgot the where condition: > SELECT *, (product_price * count_product) as sum_price FROM > shoppingcart WHERE sum_price > 50
> Best regards > Robert
> On 2 Jul., 19:15, robert henniger <robert.henni...@googlemail.com> > wrote: > > Hi to all. > > Is it possible to use mathematical operations and "extend" the > > selected resultset with additional/virtual "fields? > > Example: > > SELECT *, (product_price * count_product) as sum_price FROM > > shoppingcart
> > Additional Information:
> > I forgot the where condition:
> > SELECT *, (product_price * count_product) as sum_price FROM
> > shoppingcart WHERE sum_price > 50
> > Best regards
> > Robert
> > On 2 Jul., 19:15, robert henniger <robert.henni...@googlemail.com>
> > wrote:
> > > Hi to all.
> > > Is it possible to use mathematical operations and "extend" the
> > > selected resultset with additional/virtual "fields?
> > > Example:
> > > SELECT *, (product_price * count_product) as sum_price FROM
> > > shoppingcart
> > > Additional Information: > > > I forgot the where condition: > > > SELECT *, (product_price * count_product) as sum_price FROM > > > shoppingcart WHERE sum_price > 50
> > > Best regards > > > Robert
> > > On 2 Jul., 19:15, robert henniger <robert.henni...@googlemail.com> > > > wrote: > > > > Hi to all. > > > > Is it possible to use mathematical operations and "extend" the > > > > selected resultset with additional/virtual "fields? > > > > Example: > > > > SELECT *, (product_price * count_product) as sum_price FROM > > > > shoppingcart
Thank you Jon,
it works now. I tested it yesterday but i think i did something wrong
then.
Sorry for that!
Can i use every "mysql" function for the expression or which functions
are supported?
I am asking because in mysql you use "rand()" and this will not work.
When i use "random()" it works.
Is there something i have to keep in mind?
Best regards
PS: By the way, doctrine rocks and is a perfect tool for me.
The learning phase is a bit long but it is very cool and i am looking
forward for the release.
On 3 Jul., 05:28, "Jonathan Wage" <jonw...@gmail.com> wrote:
> > > > Additional Information:
> > > > I forgot the where condition:
> > > > SELECT *, (product_price * count_product) as sum_price FROM
> > > > shoppingcart WHERE sum_price > 50
> > > > Best regards
> > > > Robert
> > > > On 2 Jul., 19:15, robert henniger <robert.henni...@googlemail.com>
> > > > wrote:
> > > > > Hi to all.
> > > > > Is it possible to use mathematical operations and "extend" the
> > > > > selected resultset with additional/virtual "fields?
> > > > > Example:
> > > > > SELECT *, (product_price * count_product) as sum_price FROM
> > > > > shoppingcart
Yes, you can. But, Doctrine is portable by default. This means that the only things you are allowed to use are things which are portable and can work across any dbms. If you wish to use a dbms specific function then you must turn off portability.
> Thank you Jon, > it works now. I tested it yesterday but i think i did something wrong > then. > Sorry for that! > Can i use every "mysql" function for the expression or which functions > are supported? > I am asking because in mysql you use "rand()" and this will not work. > When i use "random()" it works.
> Is there something i have to keep in mind?
> Best regards
> PS: By the way, doctrine rocks and is a perfect tool for me. > The learning phase is a bit long but it is very cool and i am looking > forward for the release.
> On 3 Jul., 05:28, "Jonathan Wage" <jonw...@gmail.com> wrote: > > DQL has the same ability to specify expressions like SQL can.