Skip to content
Advertisement

Query for similar phrases

Is there any way to match ‘United States of America’ with ‘United States’ in SQL?

I have the country with the name ‘United States’ stored in the database. The query below should retrieve the item from the database with the name ‘United States’.

SELECT * FROM `countries` WHERE `name` LIKE '%United States of America%'

Thank you!

Advertisement

Answer

Is this what you want?

where 'United States of America' like concat('%', name, '%')
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement