SQL: Select like column from two tables

I have a database with two tables (Table1 and Table2). They both have a common column [ColumnA] which is an nvarchar. How can I select this column from both tables and return it as a single column in my result set?

So I'm looking for something like:

ColumnA in Table1:
a
b
c

ColumnA in Table2:
d
e
f

Result set should be:
a
b
c
d
e
f
This question and answers originated from www.stackoverflow.com
Question by (9/4/2008 5:03:25 PM)

Answer

SELECT ColumnA FROM Table1 UNION Select ColumnB FROM Table2 ORDER BY 1

Also, if you know the contents of Table1 and Table2 will NEVER overlap, you can use UNION ALL in place of UNION instead. Saves a little bit of resources that way.

-- Kevin Fairchild

Answer by

Find More Answers
Related Topics  sql  query
Related Questions
  • SQL - Select rows from two different tables

    Having this table Table "Items" itemID itemTitle itemContent and this Table "MyList" userID itemID deleted how can I select all rows from table "Items" and showing the field "deleted…
  • SQL Server: use left join to select a column from two tables as a single column

    I am trying to build a select query that will essentially left join two tables and display one column from each table as a single column. the table structure is similar to: table a: id, ema…
  • SQL - Order by column from two tables

    I have two tables: messages (messages users posted), likes (many to many relationship between users and messages - it says that user1 likes message5). messages --------- id, id_user, message, cre…
  • SQL SELECT From two tables (friendship) statement

    I have the following tables created: Table #1: tbl_Connections USE [taaraf_db] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[tbl_Connections]( [uc_Id] [int] IDEN…
  • Oracle SQL - Select from two tables

    I have two tables which are exactly the same layout, but have different data (one is current, one is history). How do I pull information from both tables? PSUDO SQL: SELECT T.TRANS_QUAN,…
  • SQL - exclude a column from SELECT query

    I have 100 columns in a table, i want to list 99 columns except a particular one, how to exclude that columns name?
  • MySql select aggregates from two tables

    In a previous question I asked how to return the dates of the LATEST tests passed by each user, based on three tables, Users , Tests and Passes . |--------|---------|---------|---------|---------…
  • SQL select: two-dimensional select with variable column count

    CREATE TABLE activities(activityid, name); CREATE TABLE activity_scores(activityid, studentid, score); CREATE TABLE students (id, name); Is there any way to write a single SELECT query that wi…
  • select max, min values from two tables

    I have two tables. Differ in that an archive is a table and the other holds the current record. These are the tables recording sales in the company. In both we have among other fields: id, name, pri…
  • SQL select statement from 2 tables

    I have a small sql question. I have 2 tables Members and Managers Members has: memberID, Name, Address Managers has: memberID, EditRights, DeleteRights EditRights and DeleteRights are of…