MySQL: get only first row of each Distinct record -
is there way first(if there more one. see item # 1) title each item , empty string title column in case title doesn't exists (see item # 2, there no title) here table schemas.
items --------------- id | created_by --------------- 1 xyz 2 abc elements ----------------- id | name ----------------- 1 title 2 description 3 type elements_text ------------------------------------------ id | item_id | elements_id | text ------------------------------------------ 1 1 1 test title 2 1 1 second title 3 1 2 description 4 2 2 test desc 5 2 3 first type 6 2 3 second type 7 2 2 desc
expected output
----------------------------------------- item_id | element_name | element_text ----------------------------------------- 1 title test title 2 title <empty string>
Comments
Post a Comment