输入: select cust_name, cust_contact, cust_email from customers where cust_state IN ('IL','IN','MI') union select cust_name, cust_contact, cust_email from customers where cust_name ='Fun4All' orderby cust_name;
1 2 3 4 5 6 7
输出: cust_name cust_contact cust_email -------------------------------------------------- Fun4All Jim Jones jjones@fun4all.com Fun4All Denise L. Stephens dstephens@fun4all.com The Toy Store Kim Howard Village Toys John Smith sales@villagetoys.com
输入: select cust_name, cust_contact, cust_email from customers where cust_state IN ('IL','IN','MI') or cust_name ='Fun4All' orderby cust_name;
1 2 3 4 5 6 7
输出: cust_name cust_contact cust_email -------------------------------------------------- Fun4All Jim Jones jjones@fun4all.com Fun4All Denise L. Stephens dstephens@fun4all.com The Toy Store Kim Howard Village Toys John Smith sales@villagetoys.com
示例三
1 2 3 4 5 6 7 8 9
输入: select cust_name, cust_contact, cust_email from customers where cust_state IN ('IL','IN','MI') unionall select cust_name, cust_contact, cust_email from customers where cust_name ='Fun4All' orderby cust_name;
1 2 3 4 5 6 7 8
输出: cust_name cust_contact cust_email -------------------------------------------------- Fun4All Jim Jones jjones@fun4all.com Fun4All Jim Jones jjones@fun4all.com Fun4All Denise L. Stephens dstephens@fun4all.com The Toy Store Kim Howard Village Toys John Smith sales@villagetoys.com