728x90
[교재 SQL 스크립트] 실전_ch1-1-1-student&winner_list.sql
USE mydb;
create table if not exists mydb.student
(
id varchar(20) null,
name varchar(15) null,
mobile varchar(11) null
)
insert into student (id, name, mobile)
values ('apple', '김사과', '01011110000');
create table if not exists mydb.winner_list
(
ranking int null,
id varchar(20) null
)
insert into winner_list (ranking, id)
values (1, 'strawberry');
SELECT a.ranking,
(SELECT mobile FROM student b WHERE b.id = a.id) AS mobile
FROM winner_list a;
SELECT a.ranking,
(SELECT mobile FROM student b WHERE b.id = a.id) AS mobile,
(SELECT name FROM student b WHERE b.id = a.id) AS name
FROM winner_list a;
SELECT a.ranking,
b.mobile,
b.name
FROM winner_list a
LEFT OUTER JOIN student b
ON a.id = b.id;
728x90
'MySQL' 카테고리의 다른 글
내일은 SQL(응용 실전편) 실전_ch1-1-3-departments&employees.sql (0) | 2024.05.20 |
---|---|
내일은 SQL(응용 실전편) 실전_ch1-1-2-product&payment.sql (0) | 2024.05.20 |
(Workbench) SSH 터널링으로 DB서버 접속(pem키가 있을 때) (2) | 2022.03.16 |
Dbeaver에서 로컬DB에 접속 못하는 현상 해결 (0) | 2022.02.11 |
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (0) | 2022.02.11 |