Use multiple select statements in sql


  • 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 .

    idfirst_namelast_nameage
    1TomMiller22
    2JohnSmith26
    3LisaWilliams30
    4CharlesDavis21
    5JamesMoore22

    The table contains data in picture following columns: , , , extort .

    idfirst_namelast_nameage
    1MilanSmith45
    2CharlesDavis21
    3MarkBacker19

    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_namelast_nameage
    TomMiller22
    JohnSmith26
    LisaWilliams30
    CharlesDavis21
    JamesMoore28
    MilanSmith45
    CharlesDavis21
    MarkBa 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