Outputting a list of production plants located in Gangwon-do (with. MySQL)
Outputting a list of production plants located in Gangwon-do (with. MySQL)
I want to solve the coding test problem, find out how to solve it differently from the retrospective of the problem I solved, and get to know.
Letโs get to the problem first.
Problem
In the FOOD_FACTORY table, please write a SQL statement that inquires about the factory ID, factory name, and address of the food factory located in Gangwon-do.
At this time, please sort the results in ascending order based on the factory ID.
The following is the FOOD_FACTORY table containing the information of the food factory.
The FOOD_FACTORY table is as follows, and FACTORY_ID, FACTORY_NAME, ADDRESS, and TLNO mean factory ID, factory name, address, and phone number, respectively.
FOOD_FACTORY table
Column name | Type | Nullable |
---|---|---|
FACTORY_ID | VARCHAR(10) | FALSE |
FACTORY_NAME | VARCHAR(50) | FALSE |
ADDRESS | VARCHAR(100) | FALSE |
TLNO | VARCHAR(20) | TRUE |
problem solving
SELECT FACTORY_ID, FACTORY_NAME, ADDRESS
FROM FOOD_FACTORY
WHERE SUBSTR(ADDRESS, 1, 3) = '๊ฐ์๋'
ORDER BY FACTORY_ID
Solution Description
The SUBSTR function was used to output queries with โGangwon-doโ in the address and sort the high-factory ID by ascending order through ORDER BY.