
Originally Posted by
r937
i was kinda hoping you would actually use mysqldump, or, alternatively exporting the table from phpmyadmin, which is where it looks like you've copied the structure from
further, it looks like you've actually used the correct datatype, DATE, instead of the strings which you alluded to earlier
dates need to be enclosed in quotes, otherwise you have arithmetic subtraction being performed with three integers
The post above consists of a export via text.
select * from travelling_details where date_from >= '2012-02-01'; - Returns a match
select * from travelling_details where date_from <= '2012-02-01'; - Returns no match
There queries are single range queries which i a currently testing, i am still yet to test within a range.
Here is an SQL DUMP
Code:
-- MySQL dump 10.13 Distrib 5.5.18, for Linux (x86_64)
--
-- Host: localhost Database: dontflysolo
-- ------------------------------------------------------
-- Server version 5.5.18-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `travelling_details`
--
DROP TABLE IF EXISTS `travelling_details`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `travelling_details` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) DEFAULT NULL,
`date_from` date DEFAULT NULL,
`date_to` date DEFAULT NULL,
`location_from` int(11) DEFAULT NULL,
`location_to` int(11) DEFAULT NULL,
`extra` text,
PRIMARY KEY (`id`),
KEY `date_from` (`date_from`,`date_to`),
KEY `date_to` (`date_to`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `travelling_details`
--
LOCK TABLES `travelling_details` WRITE;
/*!40000 ALTER TABLE `travelling_details` DISABLE KEYS */;
INSERT INTO `travelling_details` VALUES (2,10,'2012-02-09','2012-02-16',223,154,'Would like to travel with someones who's been there before preferably.');
/*!40000 ALTER TABLE `travelling_details` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2012-02-06 13:47:02
Bookmarks