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, 2 14971
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,
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,
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jim Min |
last post by:
Anyone can explain the following?
Table definition:
CREATE TABLE testdate
(
SalesDate DATETIME,
SalesTotal DOUBLE,
PRIMARY KEY (SalesDate)
)
|
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...
|
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
|
by: Paulo Jan |
last post by:
Hi all:
I have here a table with the following schema:
Table "todocinetv"
Column | Type | Modifiers...
|
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...
|
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...
|
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_...
|
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...
|
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...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |