전체 글
-
left join, right join, inner join, full outer join, self join, cross joinBackend/DB 2022. 9. 30. 15:43
1. Left join 조인문의 왼쪽 테이블의 모든결과를 가져온 후 오른쪽 데이터 매칭 매칭되는 데이터가 없는 경우 Null 2. Right join 조인문의 오른쪽 테이블의 모든 결과를 가져온 후 왼쪽테이블의 데이터를 매칭하고, 매칭되는 데이터가 없는 경우 Null 3. Inner join (교집합) 두 테이블 모두에 기준 필드의 값이 있는 레코드만 가져온다. 4. Full Outer join (합집합) 기준 필드의 값과 매치되는 레코드가 어느 한 쪽 테이블에라도 있으면 해당 레코드를 해당 테이블에서 가져온다. **단 mysql에서는 지원되지 않음 ㅠㅠ union을 조합해야함.
-
1148. Article Views I mysqlLeetCode_Study_Plan/SQL 2022. 9. 30. 14:57
https://leetcode.com/problems/article-views-i/?envType=study-plan&id=sql-i Article Views I - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com select distinct author_id as id from views where author_id = viewer_id order by author_id;
-
1581. Customer Who Visited but Did Not Make Any Transactions mysqlLeetCode_Study_Plan/SQL 2022. 9. 30. 14:54
https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions select v.customer_id, count(*) as count_no_trans from visits v left join transactions t on v.visit_id = t.visit_id where t.transaction_id is null group by v.customer_id;
-
1795. Rearrange Products Table mysqlLeetCode_Study_Plan/SQL 2022. 9. 29. 18:09
https://leetcode.com/problems/rearrange-products-table Rearrange Products Table - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com select p1.product_id, 'store1' as store, store1 as price from (SELECT product_id, store1 FROM Products) p1 where store1 is not null union select p2.prod..
-
1965. Employees With Missing Information mysqlLeetCode_Study_Plan/SQL 2022. 9. 29. 14:47
https://leetcode.com/problems/employees-with-missing-information/?envType=study-plan&id=sql-i Employees With Missing Information - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com SELECT employee_id FROM Employees WHERE employee_id NOT IN (SELECT employee_id FROM Salaries) UNION SEL..
-
1527. Patients With a Condition mysqlLeetCode_Study_Plan/SQL 2022. 9. 27. 12:51
https://leetcode.com/problems/patients-with-a-condition/?envType=study-plan&id=sql-i Patients With a Condition - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com select * from Patients where conditions like 'DIAB1%' or conditions like '% DIAB1%';
-
1484. Group Sold Products By The Date mysqlLeetCode_Study_Plan/SQL 2022. 9. 27. 12:44
https://leetcode.com/problems/group-sold-products-by-the-date/ Group Sold Products By The Date - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com select sell_date, count(distinct product) as num_sold, group_concat(distinct product) as products from Activities group by sell_date orde..