>WHERE where concat(year,period,week) as type int < 2007031
>
>Note that I'm trying to change the type of what the concat() is doing.
>Is this even possible?  If so is it possible to do it in the WHERE?

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

>The reason why I think I need to do this is that 'period' is a char(2).
>I have to have the leading zero for every entry into the database so I
>can run my less than compare to it.  Is there a better way of doing this
>than having the 'period' a char(2) type and trying to make whole
>concat() a type of int() on the fly?

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)
;

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

Good luck,
James Harvard

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

Reply via email to