Data Table TEMP Structure
--Table "temp" ddlcreate table ' temp ' ( ' page_id ' bigint () default NULL, ' section_id ' bigint () default null,< c5/> ' visit_category_id ' bigint (default null, ' cart_category_id ' bigint () default null) Engine=innodb default Charset=utf8;
data table category structure
--table "category" Ddlcreate table ' category ' ( ' category_id ' bigint () DEFAULT NULL, ' Category_name ' varchar (+) default NULL) Engine=innodb default Charset=utf8;
Business Requirements
Associate the Temp table with the category table and take out the corresponding category_name for visit_category_id and cart_category_id
Solution Solutions
Select A.page_id,a.section_id,a.visit_category_id,b.category_name,a.cart_category_id,c.category_name from Temp a Left outer joins category B on (a.visit_category_id=b.category_id) left outer joins category C on (a.cart_category_id=c.cate GORY_ID);
Query Results
SQL data table two fields associated with the same data table