Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

MySQL String Exercises: Get the locations that have minimum street length

MySQL String: Exercise-11 with Solution

Write a query to get the locations that have minimum street length.

Sample table: locations


Code:

SELECT * FROM locations
WHERE LENGTH(street_address) <= (SELECT  MIN(LENGTH(street_address)) 
FROM locations);

Sample Output:

LOCATION_ID	STREET_ADDRESS	POSTAL_CODE	CITY			STATE_PROVINCE	COUNTRY_ID
1600		2007 Zagora St	50090		South Brunswick		New Jersey	US
2400		8204 Arthur St			London					UK

MySQL Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous:Write a query to get the last word of the street address.
Next:Write a query to display the first word from those job titles which contains more than one words.

What is the difficulty level of this exercise?