Import data
Import someone else's data.
In this example you are shown how to make a mimic which essentially makes a copy of the database table so it can be freely edited
and then the newly fresh one when finished can be used to replace the out of date existing table.
Table 1 and 2 show the two separate tables and table 3 displays the results that should be inside the mimic in this example.
id | parkingSpace |
---|---|
E01 | F8 |
E02 | G22 |
E03 | F7 |
id | name | phone |
---|---|---|
E01 | Harpo | 2753 |
E02 | Zeppo | 2754 |
E03 | Groucho | 2755 |
id | name | phone | parkingSpace |
---|---|---|---|
E01 | Harpo | 2753 | F8 |
E02 | Zeppo | 2754 | G22 |
E03 | Groucho | 2755 | F7 |
DROP TABLE employeeParking;
DROP TABLE employeeCopy;
DROP VIEW mimic;
CREATE TABLE employeeParking(
id TEXT,
parkingSpace TEXT );
INSERT INTO employeeParking VALUES ('E01','F8');
INSERT INTO employeeParking VALUES ('E02','G22');
INSERT INTO employeeParking VALUES ('E03','F7');
CREATE TABLE employeeCopy (
id TEXT,
name VARCHAR(20),
phone INTEGER );
INSERT INTO employeeCopy VALUES ('E01','Harpo',2753);
INSERT INTO employeeCopy VALUES ('E02','Zeppo',2754);
INSERT INTO employeeCopy VALUES ('E03','Groucho',2755);
To allow data to be imported into your system a mimic of your system can be made and then all that needs to be done is the rows from the old copy have to be deleted and then the table can be refilled with the fresh imported copy.
This method is not completely ideal but is efficient as a temporary measure until an up to date version of the table is made.
CREATE VIEW mimic AS
SELECT employeeParking.id, COALESCE(name, employeeParking.id) AS name,
COALESCE(phone, 'Not Available') AS phone, parkingSpace
FROM employeeParking LEFT OUTER JOIN
employeeCopy ON (employeeParking.id = employeeCopy.id);
SELECT * FROM mimic;
Hack 10 Converting subqueries into joins
Hack 11 Converting aggregate subqueries into joins
Hack 16 Search for a String across columns
Hack 24 Multiply Across a Result Set
Hack 25.5 Splitting and combining columns
Hack 26 Include the rows your JOIN forgot
Hack 30 Calculate the maximum/minimum of two fields
Hack 33 Get values and subtotals in one shot
Hack 50 Combine tables containing different data
Hack 51/52 Display rows as columns
Hack 55 Import Someone Else's Data
Hack 62 Issue Queries Without Using a Table
Hack 63 Generate rows without tables
Hack 72 Extract a subset of the results
Hack 78 Break it down by Range
Hack 88 Test two values from a subquery