Examine this table that contains over two million rows of data:
CREATE TABLE ‘news_feed’ (
.id’bigint (20) NOT NULL AUTO _INCREMENT,
.news _sources_id’varchar (11) NOT NULL,
.dataline’ datetime NOT NULL,
.headline’ varchar (256) NOT NULL,
.story’ text NOT NULL,.tag varchar (32768) DEFAULT NULL,
PRIMARY KEY (‘id’)
KEY ‘dateline’ ( ‘dateline’)
)
Examine this query that returns 332 rows of date:
SELECT *
FROM news_feed
WHERE DATE(dateline)= ‘2013-01 -01’
Which change would show the greatest improvement in the response time of the query?
A.
Use the LIKE operator:
SELECT . . .WHERE dateline LIKE ‘2013-10-01&’
B.
USE the DATEDIFF function:
SELECT . . . WHERE DATEDIFF (dateline, ‘2013-01 -01’) = 0
C.
Use numeric equivalents for comparing the two dates:
SELECT. . .WHERE MOD(UNIX_TIMESTAMP (dateline), 86400 =UNIX_TIMESTAMP
(‘2013-01 -01’)
D.
Use a date range comparison:
SELECT . . . WHERE dateline >= ‘2013-01’ and dateline < ‘2013-01 -02’
D
D
http://stackoverflow.com/questions/14104304/mysql-select-where-datetime-matches-day-and-not-necessarily-time