Reputation: 87
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!
Upvotes: 1
Views: 59
Reputation: 392
For this case, you should look into an elastic search database. It has the functionality for partial filters.
Otherwise you could do the following via dynamic sql:
Alternatively, you can do a what @Gordon said for a simpler, one time solution
Upvotes: 1
Reputation: 1270463
Is this what you want?
where 'United States of America' like concat('%', name, '%')
Upvotes: 5