Alex Krohn wrote:
> Thanks for the suggestion!
> >> SELECT d.*
> >> FROM Data as d LEFT JOIN Alt as a ON d.ID = a.DataID
> >> WHERE d.Category = 5 OR a.Category = 5
> >> Any ideas would be really appreciated!
> >This OR clause is prorably is bad. I think you get much quicker result
> >if you do two different queries:
> I suppose I'm still stuck to sorting the two result sets together manually?
> I can do this really quick (both queries will use indexes):
> SELECT * FROM Data WHERE Category = 5
> SELECT d.* FROM Data, Alt WHERE Alt.Category = 5 AND Alt.LinkID =
> However, then I'm stuck trying to put them into the proper order (trying to
> get mysql to do it, not my app).
If you need some sorting on this, use a temporary table.
1) Create a temporary table (e.g. temp31650865) with the structure of the desired results.
2) Use multiple "INSERT INTO temp31650865 SELECT ..." queries to fill the above temporary
3) Get the sorted result you search for with a "SELECT ... ORDER BY ..." on this temporary
4) Drop the temporary table.
This will be faster, than querying an OR-clause.
PS: Sorry for the late answer, I was on vacation.