Generally MySQL does format conversion for you to match data types.

You can also force the CONCAT result to be integer by the following 

where concat(year,period,week) + 0 < 2007031
                               ^^^

-----Original Message-----
From: Jay Paulson (CE CEN) [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 27, 2005 12:49 PM
To: mysql@lists.mysql.com
Subject: Changing types on the fly in select queries?

I have a strange question for you all.  I've inherated some code and the
way the code works is that I can only mess with the WHERE part of a
query.  Therefore, I was wondering if something like this would be
possible.

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?  

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?

Thanks!



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

Reply via email to