I have two tables with similar columns. I would simply like to select both tables, one after another, so that if I have ‘x’ rows on table1 and ‘y’ rows on table2, I’d get ‘x + y’ rows.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You would use
UNION [ALL]for this. The tables don’t need to have the same column names but you do need to select the same number of columns from each and the corresponding columns need to be of compatible datatypesUNION ALLis preferrable toUNIONwhere there is a choice as it can avoid a sort operation to get rid of duplicates.