Originally Posted by Old Pedant
Probably, you are just missing some indexes that are needed to bring the query up to a reasonable speed.
At a MINIMUM you need indexes on the following table.fields:
But having said that... That query sure looks like it is more complex than is needed!
Do you really want to return offers.category if the howmany value will be zero?
And do you really need to use LIKE in that
WHERE countries LIKE ...??
PLEASE don't tell me that your contries field is actually a LIST of countries! Please say it isn't something like
Austria,Australia,Belgium ... please?
Lets tackle these one by one.
1. updated the following:
-- completed_offers.username -- Index
-- offers.offerid -- Unique Index
-- offers.category -- Index
2. Basically the purpose of this whole code is to combine all the categories that are alike and count how many for each and put them into a dropdown
3. My countries are stored as Austria,Australia,Belgium because each row in the 'offers' table has a different set of countries. this was the easiest way.