Answer the question
In order to leave comments, you need to log in
How to rewrite the SQL query correctly so that it does not give an error?
$sql = "SELECT m.*,pp.*,p.id,p.originalpid,p.added,p.name,p.owner,p.favorite_cover,COUNT(pp.trackid)
FROM ".nobil_om_playlists." p
inner join ".nobil_om_playlist_pos." pp on pp.playlistid = p.id
inner join ".nobil_om_songs." m on m.id = pp.trackid
WHERE p.id=" . $this->id . "
group by pp.trackid ORDER BY pp.position ASC, pp.id DESC LIMIT " . $pl_songs_limit;
Answer the question
In order to leave comments, you need to log in
Please provide the text of the error. And the final query string ( echo $sql ).
Without thinking: group by and asterisks in the select are not normal. Though mysql type forgives.
Well, then a hundred rows were grouped by pp.track_id - that is, as a result, one row, which has two dozen different pp.position "inside" - and which one and why should sql use as a sorting criterion (order by)?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question