sql - Query - definition of ( table , table ) in simple mysql inner join -
i'm reconstructing search query coz it's becoming redundant in "what see" , i'm wondering
(albums_artists, artists) ( ) in join? boosting performance?
a query uses simple inner joins, using old (sql-89) implicit join syntax:
select ma_users.name, ma_users.username, albums.id album_id, albums.upc, albums.name album_name, albums.status, albuminfos.label, date_format(albums.created, '%y-%m-%d') created_date, concat(artists.name) artist_name, count(tracks.id) total_tracks, albumstatus.description album_status albums, albuminfos, ma_users , (albums_artists, artists) , tracks ,(albumstatus, albumtypes) albums.id = albuminfos.id , ma_users.id = albums.account_id , albums.id = albums_artists.artist_id , albums_artists.artist_id = artists.id , tracks.album_id = albums.id , albums.status = albumstatus.id , albumtypes.id = albums.albumtype_id , albuminfos.label '%$keywords%' group albums.id order albuminfos.label
accepting opinions enhancements , errors need anticipate.
as far know parentheses redundant , don't aid query execution - may have been thought surrounding them tables treated differently i'm not aware of being true (or needed here).
by way, vma_users or ma_users? (most references ma_users without v)
personally don't favour way mysql allows group 'lazy' , prefer list out fields involved in grouping. and, wouldn't stick old join styles either. don't see syntax errors, , enhancements don't think there's enough information comment.
select ma_users.name , ma_users.username , albums.id album_id , albums.upc , albums.name album_name , albums.status , albuminfos.label , date_format(albums.created, '%y-%m-%d') created_date , concat (artists.name) artist_name , count(tracks.id) total_tracks , albumstatus.description album_status albums inner join albuminfos on albums.id = albuminfos.id /* vma_users ?? */ inner join ma_users on albums.account_id = ma_users.id inner join albums_artists on albums.id = albums_artists.artist_id inner join artists on albums_artists.artist_id = artists.id inner join tracks on albums.id = tracks.album_id inner join albumstatus on albums.status = albumstatus.id inner join albumtypes on albums.albumtype_id =albumtypes.id albuminfos.label '%$keywords%' group ma_users.name , ma_users.username , albums.id , albums.upc , albums.name , albums.status , albuminfos.label , albums.created /* assuming it's date times of 00:00:00 */ , albumstatus.description order albuminfos.label
well: missed inconsistency; agree spotted inner join albums_artists on albums.id = albums_artists.artist_id not right
Comments
Post a Comment