I have one table called Device
:
Device Table
id deviceName genId description overview
1 PV motor 5 motor capacity 5 motor load is good
2 puf pannel 6 puf capacity 2 puf is for small load
3 gd motor 5 motor capacity 7 motor load is very good
4 rg motor 5 capacity is 3 low capacity
Now suppose this table has thousands of records , i need to add searching of rows like , genId=5 and description Like = '%motor%' OR Overview Like='%motor%'
Search result will be
1 PV motor 5 motor capacity 5 motor load is good
3 gd motor 5 motor capacity 7 motor load is very good
I need to construct query which first it search for genId 5 from the table , and after that it search for the description and overview having text like motor. Since if my table had 100 records and only 5 of them have their genId set to 5 then my text search query will be executed on those 5 rows instead of 100 rows .
My Search query :
Select *
From Device
where (genId=5) And (description Like '%motor%' Or overview Like '%motor%')
Can any one help me to create optimized query?