dbsql/test/smoke.sql

37 lines
1.4 KiB
MySQL
Raw Permalink Normal View History

2007-03-10 19:04:07 +00:00
CREATE TABLE Person (
id NUMBER(3),
fname TEXT(20),
lname TEXT(40),
ssn TEXT(11));
2007-03-24 22:15:20 +00:00
2007-03-10 19:04:07 +00:00
CREATE TABLE Address (
person_fk NUMBER(3),
first_line TEXT(30),
second_line TEXT(30),
city TEXT(30),
state TEXT(2),
zip TEXT(5));
2007-03-24 22:15:20 +00:00
CREATE TABLE Phone (
person_fk NUMBER(3),
type TEXT(20),
number TEXT(15));
2007-03-10 19:04:07 +00:00
INSERT INTO Person VALUES (1,"John", "Doe", "111-22-3333");
INSERT INTO Person VALUES (2, "Jane", "Doe", "222-33-4444");
2007-03-24 22:15:20 +00:00
INSERT INTO Person VALUES (3, "Judy", "Schaab", "888-22-0001");
2007-03-10 19:04:07 +00:00
INSERT INTO Address VALUES (1, "20 First St.", "# 2", "Boston", "MA", "02110");
2007-03-24 22:15:20 +00:00
INSERT INTO Address VALUES (2, "20 First St.", "# 2", "Boston", "MA", "02110");
INSERT INTO Address VALUES (3, "11600 Academy Rd NE", "Apt 4511", "Albuquerque", "NM", "87111");
2007-03-10 19:04:07 +00:00
2007-03-24 22:15:20 +00:00
INSERT INTO Phone VALUES (1, "home", "617-123-4567");
INSERT INTO Phone VALUES (2, "cell", "617-222-8777");
INSERT INTO Phone VALUES (3, "home", "505-243-4670");
INSERT INTO Phone VALUES (3, "cell", "505-259-7789");
2007-03-10 19:04:07 +00:00
2007-03-24 22:15:20 +00:00
select city from Person, Address where person_fk = id and id = 1;
select number from Person, Phone where person_fk = id and fname = "Judy" and lname = "Schaab";
select * from Phone where type = "cell";
select number from Person, Phone where person_fk = id and fname = "Judy" and lname = "Schaab" and type = "cell";
select number from Person, Phone where person_fk = id and ssn = "888-22-0001" and type = "cell";