hi Benjamin, thanks,
here shortname is varchar and pcallid is integer. i need shortname and pcallid as ' callno' of length 6. pcallid starts from 1 .. 999. to get effect like for callnumber 'xxx001' i plan to add pcallid by 1000 and pick last 3 characters and concat with shortname. simply concat(ShortName , substring(Cast( (.PCallID + 1000) as varchar(10) ),2 3) ) as 'Call No' here i would like to cast (.PCallID + 1000) as varchar thanks, regards, sreedhar ----- Original Message ----- From: "Benjamin Pflugmann" <[EMAIL PROTECTED]> To: "sreedhar" <[EMAIL PROTECTED]> Cc: "mysql" <[EMAIL PROTECTED]> Sent: Monday, December 10, 2001 5:32 PM Subject: Re: is type casting available > Hi. > > On Mon, Dec 10, 2001 at 05:13:21PM +0530, [EMAIL PROTECTED] wrote: > > hi all, > > > > how can i cast a variable either from integer to varchar or varchar to > > integer in mysql. > > That's not possible in the way you ask for. Values will get > automatically converted to the column type in question. In > expressions, MySQL doesn't use "varchar", but simply string, integer > and floating point. > > You can force a string to an integer by adding 0 (like > 'SELECT "1234"+0') and an number to a string by some string functions > (like 'SELECT CONCAT(10)'). > > I assume, there are no explicit casts, because if you want to add some > number, you get the conversion implicitly by using '+'. > > If you could provide an example why you need explicit casts, maybe we > could give a more precise answer. > > Bye, > > Benjamin. > > -- > [EMAIL PROTECTED] > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php