设置DATE变量是SQL

时间:2013-11-20 09:19:14

标签: mysql-5.5 user-variables

我在下面的代码中使用DATE()变量没有任何好运 - 在语法中获取错误。尝试了SELECT @mydate:= DATE(NOW())但同样的错误。我在使用MySQL 5.5

SET @mydate = DATE(NOW())

SELECT DISTINCT(rental.id), filmCopy.location fC_id, member.id m_id, filmInfo.title fI_title,  rental.due_back,rental.returned, filmCopy.on_loan_to,reservation_date rsrvtn, reservation.id res_id
    FROM rental

INNER JOIN transactionSummary ON transactionSummary.id = rental.transactionSummary_id
INNER JOIN member ON member.id = transactionSummary.member_id
INNER JOIN filmCopy ON filmCopy.id = rental.filmCopy_id
INNER JOIN filmInfo ON filmInfo.id = filmCopy.filmInfo_id
INNER JOIN filmPriceBracket ON filmPriceBracket.filmInfo_id = filmInfo.id
AND filmPriceBracket.filmCopytype_id = filmCopy.filmCopyType_id
LEFT JOIN reservation ON reservation.filmInfo_id = filmInfo.id
AND reservation.reservation_date = @mydate 
WHERE  rental.returned IS NULL 
AND filmPriceBracket.filmCopyType_id !=24
ORDER BY  fI_folder, rsrvtn DESC, filmCopy_id, rental.due_back

0 个答案:

没有答案