Indexing



Hi Folks,

Having some wierd problems with indexing in my query. If I run the
following

explain
select basket.*, companies.Company_ID as Company_ID
from basket
inner join companies on basket.Company_ID=companies.Company_ID
where
basket.`Status`='Open'

An index is used for companies.Company_ID and basket.Status. The
minute I try to pull anything else through from the companies table
(i.e.:
select basket.*, companies.Company_ID as Company_ID, companies.Name)
It won't use the Company_ID index, even though the inner join is using
it. Why is that?

Any help or direction to investigate would be great.

Many thanks

A
.



Relevant Pages

  • Re: Indexing
    ... Having some wierd problems with indexing in my query. ... select basket.*, companies.Company_ID as Company_ID ... inner join companies on basket.Company_ID=companies.Company_ID ... It won't use the Company_ID index, even though the inner join is using ...
    (comp.lang.php)
  • Re: Counting things with SQL
    ... Here is an example for the Northwind database, ... Inner join OD ... Count All Orders Group by the OrderID ... > I would like to find the size of the basket with the most items in. ...
    (microsoft.public.sqlserver.msde)
  • Re: Attaching a check box to a max date function
    ... A somewhat complex SQL statement indeed... ... but let's focus then on the WHERE clause that you posted: ... only want to return records where Basket is True if the "basket checkbox" (I ... > false i.e. blank the query is to return all records whether the records ...
    (microsoft.public.access.queries)
  • Re: Integrating the code for a max.date function with a check box controlling it and
    ... when basket = TRUE return only the records containing a TRUE ... basket check box but when 'basket' on the form = false the query is to ... to a boolean column in the table Cost. ... > basket=true are returned and when basket and the checkbox to disable max. ...
    (microsoft.public.access.queries)
  • arrays and mySQL querys
    ... I can't get an $arrayto be used as a select query on a mySQL database. ... At the bottom of the table is a submit to basket Button ...
    (comp.lang.php)