mardi 30 juin 2015

Need filtered result Optimised query

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 like first it search for genId 5 from table , then after it search for description and overview having text like motor because if my table had 100 records and then only 5 records of genSet=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 ?

Aucun commentaire:

Enregistrer un commentaire