If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > between query not working

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-10-11, 18:15
kc1 kc1 is offline
Registered User
 
Join Date: Jul 2011
Posts: 13
between query not working

Hi everyone,

I am using codeigniter 2.03 with wamp ( php 5.3.5, apache 2.2.17, mysql 5.1.54 ). I
am having problems with some queries. I have made the
following table:

CREATE TABLE `zipcodes` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`zip` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`state` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`averageprice` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8
COLLATE=utf8_unicode_ci


when I plug 'SELECT * FROM zipcodes WHERE averageprice BETWEEN 323606.93719128 AND 110864.97021613' into phpmyadmin I get :

MySQL returned an empty result set (i.e. zero rows).

There are definitely values between 323606.93719128 AND 110864.97021613 for averageprice column.

how do I get the right answer

Thanks in advance,

Bill
Reply With Quote
  #2 (permalink)  
Old 11-10-11, 18:53
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by kc1 View Post
There are definitely values between 323606.93719128 AND 110864.97021613 for averageprice column.
how do you know?

and what does a SHOW CREATE TABLE command produce?


p.s. one of your values contains the digits "937" ... coincidence? i don't think so
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 11-10-11, 19:05
TonyF123 TonyF123 is offline
Registered User
 
Join Date: May 2008
Posts: 17
Quote:
Originally Posted by kc1 View Post
Hi everyone,

I am using codeigniter 2.03 with wamp ( php 5.3.5, apache 2.2.17, mysql 5.1.54 ). I
am having problems with some queries. I have made the
following table:

CREATE TABLE `zipcodes` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`zip` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`state` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`averageprice` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8
COLLATE=utf8_unicode_ci


when I plug 'SELECT * FROM zipcodes WHERE averageprice BETWEEN 323606.93719128 AND 110864.97021613' into phpmyadmin I get :

MySQL returned an empty result set (i.e. zero rows).

There are definitely values between 323606.93719128 AND 110864.97021613 for averageprice column.

how do I get the right answer

Thanks in advance,

Bill
323606.93719128 is larger than 110864.97021613
I think BETWEEN needs to have the minimum value first
Reply With Quote
  #4 (permalink)  
Old 11-10-11, 19:14
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by TonyF123 View Post
323606.93719128 is larger than 110864.97021613
I think BETWEEN needs to have the minimum value first
omg i can't believe i missed that

:blush:

well spotted, tony
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 11-11-11, 08:10
kc1 kc1 is offline
Registered User
 
Join Date: Jul 2011
Posts: 13
Thanks for answering guys. You were right. It works now.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On