Learning machine learning? Try my machine learning flashcards or Machine Learning with Python Cookbook.
Concatenate Multiple Table
Create Table Of Elves
-- Create table called elves
CREATE TABLE elves (
-- string variable
name varchar(255),
-- integer variable
age int,
-- string variable
race varchar(255),
-- string variable
weapon varchar(255)
)
Create Table Of Dwarves
-- Create table called dwarves
CREATE TABLE dwarves (
-- string variable
name varchar(255),
-- integer variable
age int,
-- string variable
race varchar(255),
-- string variable
weapon varchar(255)
)
Create Table Of Orcs
-- Create table called orcs
CREATE TABLE orcs (
-- string variable
name varchar(255),
-- integer variable
age int,
-- string variable
race varchar(255),
-- string variable
weapon varchar(255)
)
Insert Rows Into Elf Table
INSERT INTO elves (name, age, race, weapon)
VALUES ('Dallar Woodfoot', 25, 'Elf', 'Bow'),
('Cordin Garner', 29, 'Elf', 'Bow'),
('Keat Knigh', 24, 'Elf', 'Sword'),
('Colbat Nalor', 124, 'Elf', 'Magic')
Insert Rows Into Dwarf Table
INSERT INTO dwarves (name, age, race, weapon)
VALUES ('Kalog', 23, 'Dwarf', 'Axe'),
('Dranar', 145, 'Dwarf', 'Bow'),
('Bratar', 12, 'Dwarf', 'Axe'),
('Dragga', 23, 'Dwarf', 'Axe')
Insert Rows Into Orc Table
INSERT INTO orcs (name, age, race, weapon)
VALUES ('Wokganit', 23, 'Orc', 'Sword'),
('Wudugog', 145, 'Orc', 'Axe'),
('Wegigoth', 12, 'Orc', 'Magic'),
('Wulgha', 23, 'Orc', 'Axe')
Concatenate All Tables
-- All rows from elf table
SELECT * FROM elves
-- Concatenate with...
UNION ALL
-- All rows from dwarf table
SELECT * FROM dwarves
-- Concatenate with...
UNION ALL
-- All rows from orcs table
SELECT * FROM orcs
name | age | race | weapon |
---|---|---|---|
Dallar Woodfoot | 25 | Elf | Bow |
Cordin Garner | 29 | Elf | Bow |
Keat Knigh | 24 | Elf | Sword |
Colbat Nalor | 124 | Elf | Magic |
Kalog | 23 | Dwarf | Axe |
Dranar | 145 | Dwarf | Bow |
Bratar | 12 | Dwarf | Axe |
Dragga | 23 | Dwarf | Axe |
Wokganit | 23 | Orc | Sword |
Wudugog | 145 | Orc | Axe |
Wegigoth | 12 | Orc | Magic |
Wulgha | 23 | Orc | Axe |