Ragazzi, sto uscendo matto da questo portale, ma le soddisfazioni sono tantissime. Ecco qui la query che ho:
Fino ad ora restituisce tutto come vorrei, ma non mi stampa correttamente il'ultimo COUNT, che dovrebbe tornarmi 10 (10 perchè gli ho contati nella tabella), ma ritorna 1.Codice PHP:$sql = 'SELECT b.band_id, b.band_name, b.band_nation, b.band_add_time, b.band_view, b.band_add_id,
u.username, u.user_colour,
ue.username AS e_username, ue.user_colour AS e_user_colour,
e.edit_time, e.edit_user,
COUNT(f.fan_user) AS fans,
COUNT(e.edit_band) AS edits
FROM ' . BANDS_TABLE . ' AS b
LEFT JOIN ' . USERS_TABLE . ' AS u
ON b.band_add_id = u.user_id
LEFT JOIN ' . BANDS_FANS_BAND_TABLE . ' AS f
ON f.fan_band = b.band_id
LEFT JOIN ' . BANDS_EDITS_TABLE . ' AS e
ON e.edit_band = b.band_id
AND b.band_last_edit = e.edit_time
LEFT JOIN ' . USERS_TABLE . ' AS ue ON e.edit_user = ue.user_id
WHERE b.band_letter = \'' . strtolower($_BAND['l']) . '\'
GROUP BY b.band_id, e.edit_band';
Come posso fare per fare ciò che voglio? Devo contare in totale quante volte è ripetuto l'id nella tabella degli EDITS.
Nel caso, si può ottimizzare la aquery riducendo le righe?
Grazie in anticipo![]()

LinkBack URL
About LinkBacks
