nst
02-16-2006, 03:22 PM
Continuing my stock programm I'm trying to build, I encountered the following problem. To put it simply
this returns as a result a number of rows for the corresponding 'stock_symbol' over the given 'ref_calendar.date'
SELECT
share_prices.stock_symbol,
share_prices.price_date,
ref_calendar.date
FROM
ref_calendar
INNER JOIN share_prices ON (ref_calendar.date_id=share_prices.date_id)
WHERE
(share_prices.stock_symbol = 'BLA') AND
(ref_calendar.date > 2005-01-05)
while this
SELECT
share_prices.stock_symbol,
share_prices.price_date,
ref_calendar.`date`
FROM
ref_calendar
INNER JOIN share_prices ON (ref_calendar.date_id=share_prices.date_id)
WHERE
(share_prices.stock_symbol = 'BLA') AND
(ref_calendar.`date` BETWEEN 2005-01-05 AND 2005-02-04)
and this
SELECT
share_prices.stock_symbol,
share_prices.price_date,
ref_calendar.date
FROM
ref_calendar
INNER JOIN share_prices ON (ref_calendar.date_id=share_prices.date_id)
WHERE
(share_prices.stock_symbol = 'BLA') AND
(ref_calendar.date > 2005-01-05) AND
(ref_calendar.date < 2005-05-01)
return NULL
Why?
this returns as a result a number of rows for the corresponding 'stock_symbol' over the given 'ref_calendar.date'
SELECT
share_prices.stock_symbol,
share_prices.price_date,
ref_calendar.date
FROM
ref_calendar
INNER JOIN share_prices ON (ref_calendar.date_id=share_prices.date_id)
WHERE
(share_prices.stock_symbol = 'BLA') AND
(ref_calendar.date > 2005-01-05)
while this
SELECT
share_prices.stock_symbol,
share_prices.price_date,
ref_calendar.`date`
FROM
ref_calendar
INNER JOIN share_prices ON (ref_calendar.date_id=share_prices.date_id)
WHERE
(share_prices.stock_symbol = 'BLA') AND
(ref_calendar.`date` BETWEEN 2005-01-05 AND 2005-02-04)
and this
SELECT
share_prices.stock_symbol,
share_prices.price_date,
ref_calendar.date
FROM
ref_calendar
INNER JOIN share_prices ON (ref_calendar.date_id=share_prices.date_id)
WHERE
(share_prices.stock_symbol = 'BLA') AND
(ref_calendar.date > 2005-01-05) AND
(ref_calendar.date < 2005-05-01)
return NULL
Why?