mysql - My SQL Join more than 5 tables -
i have table named 'quote' , has following fields..
category_id subcategory_id country_id region_id rural_id notes sender_uid receiver_uid created_timestamp is_quote_active also have 'category','subcategory','country','region','rural' , 'user' tables. need sql query retrive data follows..
category_name (from 'category' table) subcategory_name (from 'subcategory' table) country_name (from 'country' table) region_name (from 'region' table) rural_name (from 'rural' table) notes sender_name (from 'user' table) receiver_name (from 'user' table) created_timestamp is_quote_active in fact need names instead of ids. i'm looking effecient way..
thanks
try this,
select quote.quote_id, quote.notes, quote.is_quote_active, quote.created_timestamp, category.category_name, subcategory.subcategory_name, rural.rural_name, region.region_name, country.country_name, s.name sname, r.name rname quote left join category on quote.category_id = category.category_id left join subcategory on quote.subcategory_id = subcategory.subcategory_id left join country on quote.country_id = country.country_id left join region on quote.region_id = region.region_id left join rural on quote.rural_id = rural.rural_id left join user s on quote.sender_uid = s.uid left join user r on quote.receiver_uid = r.uid
Comments
Post a Comment