I have a simple table:
column 1 column2 column3
AA AAAA TT
AA BB EE
AB C AABBCC
ABC XXX XYZ
AABB YYY A
now i tried to find all columns, that match e.g. 'AA%' resulting in:
column 1 column2 column3
**AA** **AAAA** null
**AA** null null
null null *AABBCC*
null null null
**AABB** null null
is that possible with one simple query? my idea was to start with unions or temporay tables, but i can't get it to work. sorry for this simple beginner question and thanks in advance!
select d1.column1, d1.column2, d1.column3 from sample d1 where d1.column1 like 'AA%'
union
select d2.column1, d2.column2, d2.column3 from sample d2 where d2.column2 like 'AA%'
union
select d3.column1, d3.column2, d3.column3 from sample d3 where d3.column3 like 'AA%'