mysql query result error!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeepjain
    Contributor
    • Jul 2007
    • 563

    mysql query result error!

    Code:
    mysql> select property1,property2,property3,property4 from mobiles where (property4 >= '2000' and property4 < '5000') ;
    +---------------+-----------+-----------+-----------+
    | property1     | property2 | property3 | property4 |
    +---------------+-----------+-----------+-----------+
    | Motorola      | M2222     | Music     | 3500      | 
    | Motorola      | W7        | Pda       | 22000     | 
    | Nokia         | 3110c     | Camera    | 2100      | 
    | Nokia         | N97       | Smart     | 25000     | 
    | Nokia         | N97 mini  | Music     | 29000     | 
    | Nokia         | X3        | Music     | 24000     | 
    | Nokia         | X6        | Music     | 21000     | 
    | Sony Erricson | G502      | Music     | 4000      | 
    +---------------+-----------+-----------+-----------+
    8 rows in set (0.00 sec)
    as you can see in the mysql query i am trying to find things b/w range 2000-5000, but things above 5000 are also getting displayed dono the reason . any help on this.
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Make sure you have the right data type for column property4. It should be INT, BIGINT or DOUBLE.

    Comment

    • pradeepjain
      Contributor
      • Jul 2007
      • 563

      #3
      yeah okie... i changed it to INT now its working,earlier it was varchar , y will it give problem when its varchar ?

      Comment

      • nbiswas
        New Member
        • May 2009
        • 149

        #4
        What is the data type of the Property4? Is it integer/numeric?

        If that is supposed to be the case then don't put that in quotes

        So instead of

        select property1,prope rty2,property3, property4 from mobiles where (property4 >= '2000' and property4 < '5000') ;

        try

        Code:
        select property1,property2,property3,property4 from mobiles where (property4 >= 2000 and property4 < 5000) ;
        Also take the help of between... and operator

        Code:
        select property1,property2,property3,property4 from mobiles where (property4 between  2000 and 5000) ;
        hope this helps

        Comment

        Working...