Dears,
myTable
ID Name Details
1 XYZ CAT BAT RAT MAT
1 XYZ ANY MANY
2 MNO TEN PEN HEN
3 ABC ONE TWO THREE FOUR
3 ABC MATTER CATTER CHATTER
4 XYZ FAT CAT CHAT
5 XYZ AN PAN CAN
6 NNN CAT ANT PAT
If I search with 'like' on column 'DETAILS'; I need to return rows as below
Search Criteria Need Output ID WHERE DETAILS LIKE '%CAT%' PRESENT AND NAME=XYZ
Results Needed:
ID
___
1
4
I have query that gives correct results but it takes more time because the table data is getting bigger so it seems checks each rows which is not required it needs to check only first occurrence of the requested word and check the next ID
myTable
ID Name Details
1 XYZ CAT BAT RAT MAT
1 XYZ ANY MANY
2 MNO TEN PEN HEN
3 ABC ONE TWO THREE FOUR
3 ABC MATTER CATTER CHATTER
4 XYZ FAT CAT CHAT
5 XYZ AN PAN CAN
6 NNN CAT ANT PAT
If I search with 'like' on column 'DETAILS'; I need to return rows as below
Search Criteria Need Output ID WHERE DETAILS LIKE '%CAT%' PRESENT AND NAME=XYZ
Results Needed:
ID
___
1
4
I have query that gives correct results but it takes more time because the table data is getting bigger so it seems checks each rows which is not required it needs to check only first occurrence of the requested word and check the next ID
Code:
SELECT DISTINCT ID FROM myTable WHERE Name='XYZ' AND (DETAILS LIKE '%CAT%')