473,322 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Difference in SELECT WHERE IN with Datetime Fields

Anyone can explain the following?

Table definition:

CREATE TABLE testdate
(
SalesDate DATETIME,
SalesTotal DOUBLE,
PRIMARY KEY (SalesDate)
)

If I use the following SQL statement I get results:

SELECT * FROM testdate
WHERE SalesDate = '2003-08-27' OR SalesDate='2003-07-27';

But I get an empty set when I use this:

SELECT * FROM testdate
WHERE SalesDate IN ('2003-08-27', '2003-07-27');

This happens on both 4.0.15 and 3.23.57.
But the above statements work the same under Microsoft SQL Server.

Why is MySQL interpreting WHERE IN and WHERE = OR = differently?

Thanks,
Jul 19 '05 #1
2 14964
BDR
According to the manual, the IN search is performed using a binary
comparison, so it's possible I guess that the SalesDate column isn't
giving the correct output for the comp operation.

This does work though:
SELECT * FROM testdate
WHERE date_format(`SalesDate`,'%Y-%m-%d')
IN('2003-08-27', '2003-07-27');
Jim Min wrote:
Anyone can explain the following?

Table definition:

CREATE TABLE testdate
(
SalesDate DATETIME,
SalesTotal DOUBLE,
PRIMARY KEY (SalesDate)
)

If I use the following SQL statement I get results:

SELECT * FROM testdate
WHERE SalesDate = '2003-08-27' OR SalesDate='2003-07-27';

But I get an empty set when I use this:

SELECT * FROM testdate
WHERE SalesDate IN ('2003-08-27', '2003-07-27');

This happens on both 4.0.15 and 3.23.57.
But the above statements work the same under Microsoft SQL Server.

Why is MySQL interpreting WHERE IN and WHERE = OR = differently?

Thanks,


Jul 19 '05 #2
BDR
According to the manual, the IN search is performed using a binary
comparison, so it's possible I guess that the SalesDate column isn't
giving the correct output for the comp operation.

This does work though:
SELECT * FROM testdate
WHERE date_format(`SalesDate`,'%Y-%m-%d')
IN('2003-08-27', '2003-07-27');
Jim Min wrote:
Anyone can explain the following?

Table definition:

CREATE TABLE testdate
(
SalesDate DATETIME,
SalesTotal DOUBLE,
PRIMARY KEY (SalesDate)
)

If I use the following SQL statement I get results:

SELECT * FROM testdate
WHERE SalesDate = '2003-08-27' OR SalesDate='2003-07-27';

But I get an empty set when I use this:

SELECT * FROM testdate
WHERE SalesDate IN ('2003-08-27', '2003-07-27');

This happens on both 4.0.15 and 3.23.57.
But the above statements work the same under Microsoft SQL Server.

Why is MySQL interpreting WHERE IN and WHERE = OR = differently?

Thanks,


Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jim Min | last post by:
Anyone can explain the following? Table definition: CREATE TABLE testdate ( SalesDate DATETIME, SalesTotal DOUBLE, PRIMARY KEY (SalesDate) )
2
by: Shaun | last post by:
Hi, I have a table called Bookings which has two important columns; Booking_Start_Time and Booking_End_Time. These columns are both of type DATETIME. Given any day how can I calculate how many...
2
by: Kieran Dutfield | last post by:
Code: ALTER PROCEDURE GetBookings ( @CurrentDate datetime, @Catergory char(10) ) AS SELECT BookingId, StartDate, PeriodStart, Catergory, Staff, Resource, Class, @CurrentDate AS Expr1
8
by: Paulo Jan | last post by:
Hi all: I have here a table with the following schema: Table "todocinetv" Column | Type | Modifiers...
2
by: Lad | last post by:
I use datetime class in my program and now I have two fields that have the datetime format like this datetime.datetime(2006, 5, 24, 16, 1, 26) How can I find out the date/time difference ( in...
3
by: bbawa1 | last post by:
Hi, I have a table which has a field ItemsReceived of type datetime. I have a grid view which has two columns. In first column i have to show the data from field ItemsReceived and in second...
5
by: Irfan Mughal | last post by:
i need ur help. i want to have CPU utilization of last 24 hrs. for time being i want to have result from 1 server. select "AVG_%_Total_Processor_Time", "WRITETIME", "MAX_...
5
by: bobh | last post by:
Hi All, Is there a difference in preformance between the two; TblNme has 36 fields across a record a query that selects all fields and the report only uses 75% of the fields, ie; Select...
1
by: Joey Fontaine | last post by:
I just noticed that, when using intellisense, the DateTime.MaxValue field has a static property icon whereas the Decimal.MaxValue field has a constant property icon. However, when looking at the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.