我有這樣 表數據master_itemMySQL的透視表到n的關係
+-------+---------+ |item_id|item_name| +-------+---------+ | 001 | Car A | | 002 | Car B | +-------+---------+
和關係到表過程
+-------+--------+ |proc_id|proc_seq| +-------+--------+ | 001 | 1 | | 001 | 2 | | 001 | 3 | | 001 | 4 | | 001 | 5 | | 002 | 1 | | 002 | 2 | | 002 | 3 | +-------+--------+
,我想導致像這樣,當我選擇ITEM_ID = 001
+-------+---------+-----+-----+-----+-----+-----+-----+-----+ |item_id|item_name|proc1|proc2|proc3|proc4|proc5|proc6|proc7| +-------+---------+-----+-----+-----+-----+-----+-----+-----+ | 001 | Car A | 1 | 2 | 3 | 4 | 5 | | | +-------+---------+-----+-----+-----+-----+-----+-----+-----+
什麼是查詢產生這個結果?
採用,而不是由數據透視表查詢做這個簡單的查詢。並在應用程序級別 – 1000111