select floor('5') <= floor('6'); TK
> -----Opprinnelig melding----- > Fra: Daniel James [mailto:[EMAIL PROTECTED]] > Sendt: 30. oktober 2001 04:32 > Til: [EMAIL PROTECTED] > Emne: Comparing strings as ints > > > Hi Everyone, > > After staring blankly at the mysql manual for a.... long time, I > thought it > might be time to ask the list... > > I have a table setup with a varchar(20) column, I am using this column to > store a price, the reason I chose varchar(20) is because the prices I am > dealing with are fairly large and I wanted to guarintee 20 digits. There > are no characters like '$' or '.' stored in this column. Now, If I select > and where this column <= somevalue everything is good and works.. > but! when > I use a string as somevalue it all goes nuts, because mysql will convert > the string to an integer if the other value in the comparison is an > integer, but if both are strings it's a slight problem. The reason I want > to compare it with a string is the data is from a web based form and > contains an escaped string. I don't want anyone playing with the database. > > Here is the problem another way... > > select '5' <= '6'; > => 1 > select '5' <= '4'; > => 0 > select '5' <= '40'; > => 0 <- eegad..... > > does anyone know how I can get around this? > > Thanks, > > Daniel > > --------------------------------------------------------------------- > 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