----- Original Message ----- From: "Jonathan Mangin" <[EMAIL PROTECTED]>
To: <mysql@lists.mysql.com>
Sent: Monday, November 21, 2005 8:48 AM
Subject: Index of JOINed table?


I have a simple query, (part of a union).
calendar is a table of only dates, `date` as PK.
sales has a multi-col index on (date, uid).

(select calendar.date as date,
       time_format(time(sales.date),'%H:%i') as time,
    from calendar
    left join sales
       on date(sales.date) = calendar.date
       and sales.uid = 'george'
    where calendar.date between '2005-08-01' and '2005-08-14')

First, I don't quite understand joins(!) on constants (sales.uid = 'george').
Is this proper, or should uid be included in where clause?

Second, explain shows no possible keys for sales.

id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY calendar range PRIMARY PRIMARY 3 NULL 11 Using where; Using index
1       PRIMARY sales   ALL     NULL    NULL    NULL    NULL    23


I guess I found the problem...

       on date(sales.date) = calendar.date

If I create separate date and time columns it lists, and uses,
possible_keys.



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to