18 lines
821 B
MySQL
18 lines
821 B
MySQL
|
CREATE SCHEMA luxury_shirts;
|
||
|
|
||
|
CREATE TABLE luxury_shirts.LuxuryShirtWithForeignKey (
|
||
|
uuid BINARY(16) NOT NULL,
|
||
|
id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||
|
typ VARCHAR(40) NOT NULL,
|
||
|
product_line VARCHAR(26) NOT NULL ,
|
||
|
customer VARCHAR(40) NOT NULL,
|
||
|
FOREIGN KEY (typ) REFERENCES shirt_shop.shirts(name)
|
||
|
);
|
||
|
|
||
|
INSERT INTO luxury_shirts.LuxuryShirtWithForeignKey SET
|
||
|
uuid = UUID_TO_BIN(UUID()),
|
||
|
typ = 'small polo shirt',
|
||
|
product_line = 'NoblesseOblige',
|
||
|
customer = 'Hans Dampf';
|
||
|
|
||
|
SELECT * FROM luxury_shirts.LuxuryShirtWithForeignKey INNER JOIN shirt_shop.shirts ON LuxuryShirtWithForeignKey.typ = shirts.name WHERE color = 'blue';
|