leetcode(14)
-
[LeetCode MySQL] 175. Combine Two Tables
175. Combine Two Tables Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId | int | | FirstName | varchar | | LastName | varchar | +-------------+---------+ PersonId is the primary key column for this table. Table: Address +-------------+---------+ | Column Name | Type | +-------------+---------+ | AddressId | int | | PersonId | int | | City | varc..
2021.02.10 -
[LeetCode MySQL] 182. Duplicate Emails
182. Duplicate Emails Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Email | +----+---------+ | 1 | a@b.com | | 2 | c@d.com | | 3 | a@b.com | +----+---------+ For example, your query should return the following for the above table: +---------+ | Email | +---------+ | a@b.com | +---------+ Note: All emails are in lowercase. Solution select email fr..
2021.02.10 -
[LeetCode MySQL] 595. Big Countries
595. Big Countries There is a table World +-----------------+------------+------------+--------------+---------------+ | name | continent | area | population | gdp | +-----------------+------------+------------+--------------+---------------+ | Afghanistan | Asia | 652230 | 25500100 | 20343000 | | Albania | Europe | 28748 | 2831741 | 12960000 | | Algeria | Africa | 2381741 | 37100000 | 188681000..
2021.02.10 -
[LeetCode MySQL] 620. Not Boring Movies
620. Not Boring Movies X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions. Please write a SQL query to output movies with an odd numbered ID and a description that is not 'boring'. Order the result by rating. For example, table cinema: +---------+-----------+--------------+-----------+ | id |..
2021.02.10 -
[LeetCode MySQL] 196. Delete Duplicate Emails
196. Delete Duplicate Emails Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. +----+------------------+ | Id | Email | +----+------------------+ | 1 | john@example.com | | 2 | bob@example.com | | 3 | john@example.com | +----+------------------+ Id is the primary key column for this table. For example, after runn..
2021.01.19 -
[LeetCode MySQL] 627. Swap Salary
627. Swap Salary Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update statement and no intermediate temp table. Note that you must write a single update statement, DO NOT write any select statement for this problem. Example: | id | name | sex | salary | |----|------|-----|---..
2021.01.19