I have two tables in SQL Server which have two similar columns.
table1 (
partID, PartName, ....
)
table2 (
sekId, Part2Name, ....
)
I need to populate one combobox in vb.net with the cummulated values of PartName
and Part2Name
so that the list can appear like being sourced from one single column, because the user might require from either. The combobox must be one that's how the design has it. Is there an SQL statement to sort me out?
U get all valuel like this:
SELECT PartName FROM table1
UNION
SELECT PartName From table2
Using the UNION T-SQL statement will join the two tables togheter
SELECT partID as IDNumber, PartName as Name FROM table1
UNION
SELECT sekID as IDNumber, Part2Name as Name From table2
ORDER BY Name
and sort the union using the renamed column
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.