MySQL INTERSECT та TABLE

Published: 26 January 2023
on channel: spa it
52
4

База та таблички з відео UNION та EXCEPT

Ті ж самі таблички - Customers та їх хоббі
(нагадую - код під відео)




DROP DATABASE base2;
CREATE DATABASE base2;

USE base2;
CREATE TABLE Customers
(
Id INT PRIMARY KEY AUTO_INCREMENT,
Age INT,
FirstName VARCHAR(20) NOT NULL,
LastName VARCHAR(20) NOT NULL,
Phone VARCHAR(20)
);


CREATE TABLE CHobby
(
Id INT PRIMARY KEY AUTO_INCREMENT,
Age INT,
FirstName VARCHAR(20) NOT NULL,
LastName VARCHAR(20) NOT NULL,
Hobby VARCHAR(20)
);

INSERT Customers(Age, FirstName, LastName, Phone)
VALUES (18,'Ganna','Velickiv','0688889977');
INSERT Customers(Age, FirstName, LastName, Phone)
VALUES (19,'Ury','Medvejuy','0688889988');
INSERT Customers(Age, FirstName, LastName, Phone)
VALUES (39,'Anton','Chernov','0687889988');

INSERT CHobby(Age, FirstName, LastName, Hobby)
VALUES (18,'Ganna','Velickiv','alcohol');

SELECT * FROM Customers;
TABLE Customers;

SELECT * FROM CHobby;
TABLE CHobby;

SELECT Customers.Id, Customers.FirstName, Customers.LastName
FROM Customers
INNER JOIN CHobby ON CHobby.FirstName=Customers.FirstName AND CHobby.LastName=Customers.LastName;


SELECT FirstName, LastName
FROM Customers
INTERSECT
SELECT FirstName, LastName
FROM CHobby;


Watch video MySQL INTERSECT та TABLE online without registration, duration hours minute second in high quality. This video was added by user spa it 26 January 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 5 once and liked it people.