Closed. This question needs to be more focused。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题。
                        
                        2年前关闭。
                                                                                            
                
        
可以说我有2个表格,如下所示。

+----Table1-----+
+---------------------------+
| FirstName| LastName | ... |
+----+----------+-----------+
| Rick     | Grimes   | ... |
| Daryl    | Dixon    | ... |


还有另一张桌子

+----Table2-----+
+---------------------------+
| FirstName| LastName | ... |
+----+----------+-----------+
| Norman   | Reedus   | ... |


我想要一条sql语句,它将给我这个输出-

| LastName |
+-----------+
| Dixon   |
| Grimes  |
| Reedus  |


设法使用工会做到这一点,但我想使用JOIN实现此结果。谢谢

最佳答案

您正在寻找union all运算符:

SELECT lastname
FROM   table1
UNION ALL
SELECT lastname
FROM   table2

10-06 16:06