I have two tables like this
profile_answers
+---------+------------+ | id | class_name | +---------+------------+ | 1 | Class
SELECT id,IFNULL(samples,'NULL') sample FROM ( SELECT AA.id, GROUP_CONCAT(DISTINCT BB.sample) samples FROM profile_answers AA LEFT JOIN educations BB ON AA.id = BB.profile_answers_id GROUP BY AA.id ) A;