Reputation: 15
I have a combo box and a table MyTable MyTable:
ID ¦ A ¦ B ¦
-------------
1 ¦ 1 ¦ 4 ¦
2 ¦ 2 ¦ 5 ¦
3 ¦ 3 ¦ 6 ¦
I have managed to get values in combobox like this.
Row Source = select A, B from MyTable
Relult:
1 ¦ 4
2 ¦ 5
3 ¦ 6
But i want to murge these 2 columns in one column and want to show like this.
Output:
1
2
3
4
5
6
I am sorry if its a repeated question but i have searched for my answer and didn't find my solution
Upvotes: 0
Views: 42
Reputation: 66
You can add ORDER BY ASC at the end, to be sure if the data are not arranged in the order in the table.
select a as 'a-b' from MyTable
union
select b as 'a-b' from MyTable
order by 'a-b' asc
Or demo.
Upvotes: 1
Reputation: 454
DECLARE @MyTable TABLE (ID int, A int, B int)
INSERT INTO @MyTable VALUES
(1, 1, 4)
, (2, 2, 5)
, (3, 3, 6)
SELECT Output = A FROM @MyTable
UNION
SELECT Output = B FROM @MyTable
Upvotes: 1
Reputation: 15
I have managed to get my solution using VN'sCorner solution
Row Source = select A as Colmn from MyTable
Union All
select B as Colmn from MyTable
And boom i have an output Output:
1
2
3
4
5
6
Upvotes: 0
Reputation: 1552
Use Union All, Query will be as below:
select A as Colmn from MyTable
Union All
select B as Colmn from MyTable
Upvotes: 1