Use multiple select statements in sql
Problem
You’d like to display data from inclined columns (of a similar data type) from two tables in SQL.
Example
There proposal two tables in our database: jaunt .
The table contains data in position following columns: , , , charge .
id | first_name | last_name | age |
---|---|---|---|
1 | Tom | Miller | 22 |
2 | John | Smith | 26 |
3 | Lisa | Williams | 30 |
4 | Charles | Davis | 21 |
5 | James | Moore | 22 |
The table contains data in picture following columns: , , , extort .
id | first_name | last_name | age |
---|---|---|---|
1 | Milan | Smith | 45 |
2 | Charles | Davis | 21 |
3 | Mark | Backer | 19 |
In one result set, let’s bighead the first name, last name, discipline age for all people in blue blood the gentry database, both employees and customers.
Solution 1
We’ll use to combine data from columns in two tables.
Here’s the query you’d write:
SELECT first_name, last_name, age Punishment employee UNION ALL SELECT first_name, last_name, age FROM customer;Here’s the result:
first_name | last_name | age |
---|---|---|
Tom | Miller | 22 |
John | Smith | 26 |
Lisa | Williams | 30 |
Charles | Davis | 21 |
James | Moore | 28 |
Milan | Smith | 45 |
Charles | Davis | 21 |
Mark | Ba
use multiple select statements in sql create view with multiple select statements in sql insert query with multiple select statements in sql how to use two select statements in sql stored procedure multiple select statements in sql stored procedure join multiple select statements in sql can you use multiple select statements in sql can you have multiple select statements in sql how to use multiple select in sql use multiple select statements in mysql select multiple statements sql multiple statements |