sql - Include a string in Select Query -
i'm wondering can query below?
select america, england, distinct (country) tb_country
which (my intention to) display :
america england (list of distinct country field in tb_country)
so point display (for example) america , england if distinct country field returns nothing. need query list select dropdown, , give sticky values user can pick, while allowing add new country wish.
it goes without saying, should 1 row in tb_country has value of america or england, not show duplicate in query result. if tb_country has list of values :
germany england holland
the query output :
america england germany holland
you need use union:
select 'america' country union select 'england' country union select distinct(c.country) country tb_country c
union remove duplicates; union not (but faster it).
the data type must match each ordinal position in select clause. meaning, if first column in first query int, first column unioned statements afterwards need int or null
.
Comments
Post a Comment