T
T
Tiberian2017-07-26 23:53:11
MySQL
Tiberian, 2017-07-26 23:53:11

Why does MySql add zero to SUM(value)?

Actually, there is a request:

select u.*, s.name as status_name, s.color as status_color, max(l.lvl) as lvl, sum(pow.value) as pow
from do_user u
join do_levels l
JOIN do_user_status s ON u.status = s.id 
JOIN (select * from do_user_power where type = 1) pow ON u.id = pow.uid
WHERE u.id = 5 AND u.exp >= l.exp

pow outputs the value 3230 when a simple select with the same options outputs the number 323.
Why does mysql add 0 to the value and how can I get rid of it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tiberian, 2017-07-27
@Tiberian

In general, the data on the hosting sites differed, yes.
Made an import from where it worked.

F
Fortop, 2017-07-27
@Fortop

First, you wrote nonsense in the request.
Confused in a pack of identical aliases for tables and columns.
Secondly, the main problem you have is in JOIN.
The amount of data you have in a simple query and in a JOIN query is different, respectively, and different results.
Well, different behavior on hostings can also be due to different data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question