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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -