This is an interesting example. Better formatted:
SELECT SQL_CALC_FOUND_ROWS *, t.name as tname FROM video, type as t INNER JOIN user ON video.seller = user.id WHERE video.type2 = t.id AND thumbnail_blobKey != '' AND disabled = 0 AND is_reel = 0 AND price!= 0 AND video.type != 4 GROUP BY video.id ORDER BY video.id DESC LIMIT 0, 10
The problem is that the video columns are not understood in the rest of the from clause due to,. This is how the comma works. Interestingly, it can be eliminated simply by replacing it with the logical equivalent of cross join :
SELECT SQL_CALC_FOUND_ROWS *, t.name as tname FROM video cross join type as t INNER JOIN user ON video.seller = user.id WHERE video.type2 = t.id AND thumbnail_blobKey != '' AND disabled = 0 AND is_reel = 0 AND price!= 0 AND video.type != 4 GROUP BY video.id ORDER BY video.id DESC LIMIT 0, 10
This is explained in the documentation , and the reason has priority. A comma has a lower priority than cross join . Thus, the connections in your expression are evaluated as "join video (type join user)". Since the second join is interpreted first, the columns in the video not known.
However, there is really a connection on the table, so itβs better to write how:
SELECT SQL_CALC_FOUND_ROWS *, t.name as tname FROM video join type t on video.type2 = t.id INNER JOIN user ON video.seller = user.id WHERE thumbnail_blobKey != '' AND disabled = 0 AND is_reel = 0 AND price!= 0 AND video.type != 4 GROUP BY video.id ORDER BY video.id DESC LIMIT 0, 10
source share