Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > Database
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

Database Database problems or need to ask a question? maybe something to do with sql injections or a database software question. Database topics cover MySQL, PostgreSQL, Oracle, SQL Server or anything else related to databases.

Google
Reply
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 9:33 PM   #1
Paul Lautman
 
Paul Lautman's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Wierd query result on MySQL 5 system

I have the following table (complete with sample data).
When I run the query below on a mysql 4.1.14 system, the only row returned
is row 4 as expected.
However, when I run the same query on a mysql 5.0.19 system, I get rows 2, 3
& 4; which is not what I would expect.
I have found that if I replace the "date_add( Reminder_Sent, INTERVAL 7
DAY )" with a hard coded '2006-01-15', then I get the expected row 4 only,
but that defeats the object of the query as the dates in Reminder_Sent are
not normally always the same.

Can anyone point me to what is going on here?

TIA
Regards
Paul Lautman


CREATE TABLE `balls_in_play2` (
`Ball_Number` tinyint(2) NOT NULL default '0',
`Name` varchar(50) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
`Expiry_Date` date NOT NULL default '0000-00-00',
`Reminder_Sent` date NOT NULL default '0000-00-00',
PRIMARY KEY (`Ball_Number`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `balls_in_play2`
--

INSERT INTO `balls_in_play2` (`Ball_Number`, `Name`, `email`, `Expiry_Date`,
`Reminder_Sent`) VALUES
(1, 'John Doe', '', '2007-03-31', '2006-01-01'),
(2, 'Hilary Smith', '', '2006-11-04', '2006-01-01'),
(3, 'Wendy Jones', '', '2006-10-28', '2006-01-01'),
(4, 'Fred Brown', '', '2006-05-06', '2006-01-01');

SELECT *
FROM balls_in_play2
WHERE (expiry_date BETWEEN date_add( Reminder_Sent, INTERVAL 7 DAY ) AND
date_add( current_date, INTERVAL 7 DAY ));


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 9:33 PM   #2
Paul Lautman
 
Paul Lautman's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Wierd query result on MySQL 5 system

To see the problem first hand, I have set up
http://www.sunnyacres.co.uk/bb/bbqt.php
where you can run the query below to see the results.
You can also run the query

SELECT *, date_add( Reminder_Sent, INTERVAL 7 DAY ), date_add( current_date,
INTERVAL 7 DAY ) FROM balls_in_play2 WHERE (expiry_date BETWEEN date_add(
Reminder_Sent, INTERVAL 7 DAY ) AND date_add( current_date, INTERVAL 7
DAY ));

to see that the expiry_date is not within the bounds.

Paul Lautman wrote:
> I have the following table (complete with sample data).
> When I run the query below on a mysql 4.1.14 system, the only row
> returned is row 4 as expected.
> However, when I run the same query on a mysql 5.0.19 system, I get
> rows 2, 3 & 4; which is not what I would expect.
> I have found that if I replace the "date_add( Reminder_Sent, INTERVAL
> 7 DAY )" with a hard coded '2006-01-15', then I get the expected row 4
> only, but that defeats the object of the query as the dates in
> Reminder_Sent are not normally always the same.
>
> Can anyone point me to what is going on here?
>
> TIA
> Regards
> Paul Lautman
>
>
> CREATE TABLE `balls_in_play2` (
> `Ball_Number` tinyint(2) NOT NULL default '0',
> `Name` varchar(50) NOT NULL default '',
> `email` varchar(50) NOT NULL default '',
> `Expiry_Date` date NOT NULL default '0000-00-00',
> `Reminder_Sent` date NOT NULL default '0000-00-00',
> PRIMARY KEY (`Ball_Number`)
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>
> --
> -- Dumping data for table `balls_in_play2`




 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Featured Websites
Free Space
Free Space
Free Space Free Space
Reply
Tags: , , , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mysql result to array Jaak Database 2 07-01-2007 6:39 PM
MySQL Query Cache Not Working: MySQL 5 / Windows XP Good Man Database 0 07-01-2007 6:25 PM
Re-using query result Nico Schuyt PHP 3 07-01-2007 4:18 PM
Joining many results from one table with one result from another in one query Piotr Chmielewski Database 0 06-10-2007 12:20 AM
Mysql result to array Jaak Database 2 06-10-2007 12:18 AM


Featured Websites




All times are GMT +1. The time now is 7:19 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98