I can’t get this right and I’m still working with joins, so it’s likely wrong. I have 3 data tables and 1 “summary” table which is full of my submitted value id’s.
I want to sum up value ID columns from 2 different tables and associate them with the current date and user. It does, but only for yesterday? I need it to change the query to the current day. I tried getting CURDATE() in there, but I’m clearly not doing it right.
SELECT U.user_name, SUM(T.cut_timetotal) AS sum_time, SUM(C.cuts_total) AS sum_cuts, DATE(S.submit_date ) AS date
FROM summary S
JOIN cut_info C ON S.cuts_id = C.cuts_id
JOIN users U ON U.user_id = S.user_id
JOIN timeT ON T.time_id = S.time_id
GROUP BY U.user_name
This should provide the answer you seek:
Using
is better than
as the former will use an index, if found, and the latter will not.