add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
id created_date sample_1 sample_2 sample_3 sample_4 sample_7 sample_8_1 sample_8_2 sample_9 sample_10
1 2019-05-17 06:19:13 aaa bbb ccc ddd eee fff ggg 0 0
Dataid sample_id sample_title
400 1 Fname
400 2 Sname
400 3 Lname
400 4 sample
400 7 sample1
400 8 Name
400 9 checkbox
400 10 checkbox
Dataid sample_id option_id optionss
400 9 1 First
400 9 2 second
400 9 3 Third
400 10 1 First
400 10 2 second
400 10 3 Third
@sql
SELECT sample_1 Fname,sample_2 Sname,sample_3 Lname,sample_4 sample,sample_7 sample1,sample_8 Name,sample_9 checkbox,sample_10 checkbox FROM TableData_400
CONCAT( 'SELECT ',
          GROUP_CONCAT(CONCAT('sample_',
                              te.sample_id,
                              CASE WHEN teo.option_id>0 THEN
                                    CONCAT('_',teo.option_id)
                       
SELECT sample_9_1 checkbox,sample_9_2 checkbox,sample_9_3 checkbox,sample_10_1 checkbox,sample_10_2 checkbox,sample_10_3 checkbox,sample_1 Fname,sample_2 Sname,sample_3 Lname,sample_4 sample,sample_7 sample1,sample_8 Name FROM TableData
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 result will be like this ,
if (sample title= check box  then no need to' at line 1