> You can cast data tyes explicitly:
> http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html

Now that is cool.  Too bad we are using MySQL 3.23.x on our production box.  I 
can't use it. :(

> If this table is going to get large then you might find it too slow to use 
> that method. Your query is 
> logically the same as this (assuming integer columns):
>
> WHERE
>  (year > 2007) OR
>  (year = 2007 AND period > 3) OR
>  (year = 2007 AND period = 3 AND week > 1)
> ;

I'm not quite sure if this will work. For the following reasons.

- period is of type char(2) so I can have the leading zero for the concat().  
Is it possible to compare a char() and an int() value? example '4' > 2?
- The values in the database for period are 01 through 13.  The values of week 
are 1 through 4.  The values of year is obvious.  With the way the values are 
set I'm not sure if this WHERE you have will work on not. Guess I'll have to do 
some testing.

> Can't remember off the top of my head if that would be able to use an index 
> on (year,period,week) 
> though. Anyone?

That would be intersting to see if that did work.

Thanks for the help!

Reply via email to