在组合框的 1 列中清除 2 列表数据



我有一个组合框和一个表格 MyTable 我的表格:

ID ¦ A ¦ B ¦
-------------
1  ¦ 1 ¦ 4 ¦
2  ¦ 2 ¦ 5 ¦
3  ¦ 3 ¦ 6 ¦

我已经设法在这样的组合框中获取值。

Row Source = select A, B from MyTable

嗤之以鼻:

1 ¦ 4
2 ¦ 5
3 ¦ 6

但是我想在一列中将这两列删除,并希望像这样显示。

输出:

1
2
3
4
5
6

如果这是一个重复的问题,我很抱歉,但我已经搜索了我的答案,但没有找到我的解决方案

使用 Union All,查询将如下所示:

select A as Colmn from MyTable
Union All
select B as Colmn from MyTable
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

您可以在末尾添加 ORDER BY ASC, 以确定数据是否未按表中的顺序排列。

select a as 'a-b' from MyTable union select b as 'a-b' from MyTable order by 'a-b' asc

或演示。

我已经设法使用VN的角落解决方案获得了我的解决方案

Row Source = select A as Colmn from MyTable
Union All
select B as Colmn from MyTable

繁荣我有输出 输出:

1
2
3
4
5
6

最新更新