2014-10-18 57 views
0
SELECT * 
FROM PATIENT 
WHERE PATIENTNUM = (SELECT PATIENTNUM 
        FROM CONSULTATION 
        WHERE CONSULTATIONDATE = 
        (SELECT DATE_ADD(curdate(), INTERVAL 1 DAY) AS DAYTOM); 

這是行不通的。當我在哪裏不工作時使用date_add,爲什麼?

但是,當我只插入這個

SELECT DATE_ADD(curdate(), INTERVAL 1 DAY) AS DAYTOM 

其工作...

爲什麼?

+0

它不工作意味着什麼?什麼不工作? – 2014-10-18 07:15:24

+0

什麼是錯誤顯示 – Girish 2014-10-18 07:18:28

+0

#1064 - 第6行的語法錯誤 – youngji 2014-10-18 07:20:34

回答

1

我認爲正確的做法是

SELECT * 
    FROM PATIENT 
    WHERE PATIENTNUM IN (SELECT PATIENTNUM 
       FROM CONSULTATION 
       WHERE CONSULTATIONDATE IN (SELECT DATE_ADD(curdate(), INTERVAL 1 DAY)    AS DAYTOM)); 
0

您錯過了一個支架?

SELECT * 
FROM PATIENT 
WHERE PATIENTNUM = (SELECT PATIENTNUM 
        FROM CONSULTATION 
        WHERE CONSULTATIONDATE = (SELECT DATE_ADD(curdate(), INTERVAL 1 DAY) AS DAYTOM)); 
相關問題