By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
id | created_date | sample_1 | sample_2 | sample_3_1 | sample_3_2 | sample_3_3 | sample_4_1 | sample_4_2 | sample_4_3 |
---|---|---|---|---|---|---|---|---|---|
1 | 2019-05-17 06:19:13 | aaa | 1 | 1 | 1 | 1 | Address1 | Address2 | Address3 |
2 | 2019-05-17 06:19:13 | bbb | 1 | 1 | 0 | 0 | Address1 | Address2 | Address3 |
Dataid | sample_id | sample_title | sample_type |
---|---|---|---|
400 | 1 | Name | Text |
400 | 2 | Gender | radio |
400 | 3 | Languages Known | Check Box |
400 | 4 | Address | Address |
Dataid | sample_id | option_id | optionss |
---|---|---|---|
400 | 2 | 1 | Male |
400 | 2 | 2 | Female |
400 | 3 | 1 | English |
400 | 3 | 2 | Hindi |
400 | 3 | 3 | Tamil |
CONCAT( 'SELECT ', GROUP_CONCAT(CONCAT('sample_', te.sample_id, CASE WHEN teo.option_id>0 THEN CONCAT('_','teo.option_id') |
---|
SELECT sample_2_teo.option_id Gender,sample_2_teo.option_id Gender,sample_3_teo.option_id Languages Known,sample_3_teo.option_id Languages Known,sample_3_teo.option_id Languages Known,sample_1 Name,sample_4 Address FROM TableData_400 |
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'expected output will be two tables.
First one
id Dataid created_date ' at line 1