you may try LENGTH()
.
select product_name ,length(product_name) as the_length from your_table
where product_name LIKE '%dead space%'
ORDER BY length(product_name)
limit 1
문제
Let's say, I have 2 product names: dead space and dead space limited edition, and I want to group them by "product_name" to select "dead space" in a mysql query. So I want the query to select the "product_name" with the shortest string if the where caluse is "product_name LIKE '%dead space%'".
Thanks a lot,
해결책
you may try LENGTH()
.
select product_name ,length(product_name) as the_length from your_table
where product_name LIKE '%dead space%'
ORDER BY length(product_name)
limit 1
다른 팁
Please try this query
select * from table where product_name LIKE '%dead space%'
HAVING length(product_name ) = min(length(product_name ))