Trying to add a new field "id field" to a simple union all sql query in Microsoft access like this one:
SELECT table1.name, table1.age FROM table1
UNION ALL
SELECT table2.name, table2.age FROM table2
UNION ALL
SELECT table3.name, table3.age FROM table3
;
which starts from 1 and increment automatically , is that doable?
See if this works
SELECT ROW_NUMBER() OVER (ORDER BY name), *
FROM (
SELECT table1.name, table1.age FROM table1
UNION ALL
SELECT table2.name, table2.age FROM table2
UNION ALL
SELECT table3.name, table3.age FROM table3
) x
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.