Contents

Outputting a list of production plants located in Gangwon-do (with. MySQL)

   Nov 3, 2024     2 min read

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 nameTypeNullable
FACTORY_IDVARCHAR(10)FALSE
FACTORY_NAMEVARCHAR(50)FALSE
ADDRESSVARCHAR(100)FALSE
TLNOVARCHAR(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.