简体   繁体   中英

Union All Command in SQL

SELECT  a.VPNID||'|'||a.PUBLICNUMBER||'|'||a.PRIVATENUMBER   from virtualterminal a 
UNION ALL
SELECT  b.VPNID||'|'||b.PUBLICNUMBER||'|'||b.PRIVATENUMBER||'|'||b.PROFILEID from terminal b;

This is the code , but in the first statement as you can see there is no PROFILEID column. I would like to write " null " to that column because we don't know the PROFILEID of them. How can I write "null" to that column ?

Try this Query:

SELECT  a.VPNID||'|'||a.PUBLICNUMBER||'|'||a.PRIVATENUMBER||'|'||'NULL'
from  virtualterminal a 
UNION ALL
SELECT  b.VPNID||'|'||b.PUBLICNUMBER||'|'||b.PRIVATENUMBER||'|'||b.PROFILEID 
from terminal b;

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM