4
Reply

SQL Query - Match each word

Riddhi Valecha

Riddhi Valecha

Oct 30 2017 11:42 AM
191

Table – tbl_locations

ID startlocation endlocation
1 Ghansoli,Sector-5, Navi Mumbai  Thane
2 Palava, Navi Mumbai Airoli, Sector - 10
3 Kalyan, Sector-15 Cabin-3A, Capgemini, Airoli
4 Navi Mumbai Knowledge Park, Airoli, Navi Mumbai
5 Ambernath, Navi Mumbai Airoli

User Input – Cabin-3A, Airoli

Query-

Select * from tbl_locations where startlocation like ‘%Cabin-3A %’ or startlocation like ‘%Airoli%’ or endlocation like ‘%Airoli%’or endlocation like ‘%Cabin-3A %’

Steps –

1.There are 2 words – Cabin-3A and Airoli.

I need to match both the words with two columns of the table.

How do I get the output?


Answers (4)