What would an ideal index look like for the following query?
$query="SELECT field1,field2,field3,field4,field5 FROM table WHERE field6 LIKE '%$value1%' AND field7!=''";
And this query:
$query="SELECT field1,field2,field3,field4,field5 FROM table WHERE field6='$value1' AND field7!=''";
Or this query:
$query="SELECT field1,field2,field3,field4,field5 FROM table WHERE field6='$value1' OR field7='$value2';
Or this one:
$query="SELECT field1,field2,field3,field4,field5 FROM table WHERE field6='$value1';
Would they all use different indexes or would it be best if they used the same one? What if I had other queries that selected different fields? Which field would I put the index on and what other fields do I need to add to the index(es)?
How would mysql know which index to use if many of them had the same fields added to them? Examples would be great.
Thanks.