我有這些表。如何從創建虛擬列的表中獲取不同值的「類型」 - MySQL
tb_employee:
ID_EMP NAME_EMP
1 Employee 1
2 Employee 2
3 Employee 3
4 Employee 4
tb_requirements:
ID_REQ DESCRIPTION_REQ TYPE_REQ
1 Requirement 1 1
2 Requirement 2 1
3 Requirement 3 1
4 Requirement 4 2
5 Requirement 5 2
6 Requirement 6 2
7 Requirement 7 2
tb_detail:
ID_DET ID_EMP ID_REQ
1 1 1
2 1 2
3 1 4
4 2 1
5 2 6
6 3 4
7 3 7
我需要ŧ Ø做出SELECT QUERY
計算每個員工有多少requirements
得到和類型,像這樣:
ID_EMP NAME_EMP TYPE_REQ1(virtual column) TYPE_REQ2 (virt. c.)
1 Employee 1 2 4
2 Employee 2 1 1
3 Employee 3 0 2
4 Employee 4 0 0
我真的不知道該怎麼做。
正確的DDL和/或sqlfiddle可能有幫助,加上SET – Strawberry