Search code examples
mysqlirowmultiple-columns

get MySQL table results rows as columns


I have a table like this

enter image description here

and i want a 1 query that reference_id = 1 and reference fields equal to title and alias and introtext

expected result: title -> හැඳින්වීම

alias -> overview-si

introtext ->

ධීවර

is it possible? and how can I get it ?


Solution

  • if you have refence id and that three reference_field values, use

    SELECT reference_field,value FROM tbl_name WHERE reference_id=1 AND ( reference_field='title' OR reference_field='alias' OR reference_field='introtext)