Reputation: 1150
I have a record in the database table with Street_Name "Park Avenue 10" in Street table.
I want to retrieve the record like
SELECT *
FROM Street
WHERE Street_Name LIKE '%Park Ave 10%'
The current like operator does not give the result "Park Avenue 10" for the above query.
How can I split the word with spaces and check the like operator for each word to get "Park Avenue 10" in MSSQLSERVER
Upvotes: 2
Views: 195
Reputation: 1616
Select * from Street where Street_Name like '%Park%Ave%10%'
this will help.
for more details refer this Link
Upvotes: 2
Reputation: 8337
If it will be in the same order Park
then Ave
then 10
then you can use
Select * from Street where Street_Name like '%Park%Ave%10%'
else
Select * from Street where Street_Name like '%Park%' and Street_Name like '%Ave%' and Street_Name like '%10%'
Upvotes: 2
Reputation: 2523
Select * from Street where Street_Name like REPLACE('%Park Ave 10%',' ', '%')
Upvotes: 4