Friday, 15 June 2012

Mysql - select from two table as two values -



Mysql - select from two table as two values -

i cannot understand why query

select sum(date(date) = '2014-11-2') `rate` `ratings` union select count(*) `users` `user`

doesn't create 2 values - rate, users in query 1 - rate - 2 values.

result:

rate 6 10

expected result:

rate users 6 10

do know, what's wrong query?

you should join instead of union.

based on info shared , result want achieve, query this:

select sum(date(date) = '2014-11-2') `rate`, ( select count(*) `user` ) `users` `ratings`

...but lacks of relations/conditions between tables

mysql

No comments:

Post a Comment