正在苦苦尋找這個MySQL查詢。當我拿出WHERE子句時,所有結果都會顯示給用戶。所以這不是問題的PHP輸出。我很確定它在WHERE子句中,但我一直被卡住了很長時間,無法解決。MySQL Query - SELECT DISTINCT ...(WHERE)問題
$test = $db->query
("SELECT DISTINCT(a.id), a.name
FROM test AS a LEFT JOIN(testusers AS b,testclasses AS c, userclasses AS d)
ON (c.classID = d.classID AND a.id = b.testID)
WHERE d.userID='" . $_SESSION["id"] . "' OR b.userID= '" . $_SESSION["id"] . "'
GROUP BY a.id");
感謝您的幫助!
非常感謝,你已經解決了我的問題! – Jimmy 2011-02-28 20:22:19