Select 两个表之间的日期?
Select two tables between dates?
我收到这个错误:
Incorrect syntax near '2020-05-29'.
如何解决这个问题?
SELECT Borrower.BorrowedDate, BorrowerDetails.DueDate
FROM Borrower, BorrowerDetails
WHERE Borrower.BorrowedDate BETWEEN '2020-05-28' AND BorrowerDetails.DueDate '2020-05-29'
Between
好像不支持两个字段
您可以使用:
SELECT Borrower.BorrowedDate, BorrowerDetails.DueDate
FROM Borrower, BorrowerDetails
WHERE Borrower.BorrowedDate >= '2020-05-28' AND BorrowerDetails.DueDate <='2020-05-29'
BETWEEN
不适用于该格式。您需要更改数据格式或对这些日期使用纪元时间。
SELECT Borrower.BorrowedDate, BorrowerDetails.DueDate
FROM Borrower, BorrowerDetails
WHERE Borrower.BorrowedDate >= 20200528
AND BorrowerDetails.DueDate <= 20200529;
别忘了删除单引号。我们像数字一样比较它,而不是字符串。
我收到这个错误:
Incorrect syntax near '2020-05-29'.
如何解决这个问题?
SELECT Borrower.BorrowedDate, BorrowerDetails.DueDate
FROM Borrower, BorrowerDetails
WHERE Borrower.BorrowedDate BETWEEN '2020-05-28' AND BorrowerDetails.DueDate '2020-05-29'
Between
好像不支持两个字段
您可以使用:
SELECT Borrower.BorrowedDate, BorrowerDetails.DueDate
FROM Borrower, BorrowerDetails
WHERE Borrower.BorrowedDate >= '2020-05-28' AND BorrowerDetails.DueDate <='2020-05-29'
BETWEEN
不适用于该格式。您需要更改数据格式或对这些日期使用纪元时间。
SELECT Borrower.BorrowedDate, BorrowerDetails.DueDate
FROM Borrower, BorrowerDetails
WHERE Borrower.BorrowedDate >= 20200528
AND BorrowerDetails.DueDate <= 20200529;
别忘了删除单引号。我们像数字一样比较它,而不是字符串。