我有这个,EAV方法:
Forms_data [id | form_id | survey_id | key | value ]
[1 | 1 | 1 | q1 | Male ]
[2 | 1 | 1 | q2 | 1/1/76]
[3 | 2 | 1 | Car | Honda]
[4 | 2 | 1 | Eng | Petrol]
[5 | 1 | 2 | q1 | Fem ]
[6 | 1 | 2 | q2 | 2/3/81]
[7 | 2 | 2 | Car | Ford ]
[8 | 2 | 2 | Eng | Diesel]
然后我想创建视图,例如:
查看表单 ID 1:
[survey_id | q1 | q2 ]
[ 1 | Male | 1/1/76 ]
[ 2 | Fem | 2/3/81 ]
查看表单 ID 2:
[survey_id | car | eng ]
[ 1 | Honda | Petrol ]
[ 2 | Ford | Diesel ]
我将如何在 MySQL 中执行此操作?