Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2006
    Posts
    1

    Exclamation Unanswered: implement logical condition on varchar

    My current table structure is :

    TitleID : int
    Text : varcahar(20);

    and table holds data like

    TitleId Text
    ------------- ---------------
    2 20
    3 45
    8 90
    4 30
    5 60

    Now my client wants to fetch those records whose text>30 and text<=50. I can not change datatype form varchar to any numeric data type.

    If i use that logical condition results does not comes properly and it is very normal. Can anybody tell me how i can solve this problem without change datatype.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    be careful, TEXT is a reserved word
    Code:
     where cast(`Text` as signed) > 30 
       and cast(`Text` as signed) <= 50
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •