List:General Discussion« Previous MessageNext Message »
From:Alex Krohn Date:November 18 1999 12:46am
Subject:using index with or's..
View as plain text  
Hi,

I couldn't see an answer in 10.4 in the manual or in the mailing list,
but I know this has been discussed before.

If I have two tables:

Table A			Table B
ID			AID
CID			CID

and want to pull all records like so:

SELECT A.*
>FROM   A LEFT JOIN ON A.ID = B.AID
WHERE  (A.CID = something) OR (B.CID = something)

Can this be done so that it uses indexes? I can't seem to figure out how
to pull this information from the database in one query (as I want to
apply ordering to this) and be optimized. 

I remember Monty saying that Mysql used indexes in OR clauses only under
certain conditions, just don't remember what those are. =)

Cheers,

Alex

--------------------  Gossamer Threads Inc.  ----------------------
Alex Krohn                        Email: alex@stripped
Internet Consultant               Phone: (604) 687-5804
http://www.gossamer-threads.com   Fax  : (604) 926-9320

Thread
using index with or's..Alex Krohn18 Nov
  • Stored ProceduresChristian Schrader18 Nov
    • Example problemKevin Waterson18 Nov
      • Re: Example problemPaul DuBois18 Nov