0
我想從一個表中有多個其他表匹配的表中的行。mysql匹配多個和的和或的
這是我正在運行的查詢。
SELECT qt.*, DATEDIFF(CURRENT_DATE, STR_TO_DATE(up.DOB, '%m-%d-%Y'))/365 AS Age
FROM UserProfile AS up, Game AS g, QuestionTable AS qt
WHERE NOT EXISTS(SELECT * FROM Options WHERE UserID = 75 AND QID = qt.QID AND DateTime >= CURDATE())
AND g.Active = 1 AND g.QID = qt.QID
AND (((g.Gender = up.Gender OR g.Gender = 'B') AND ((g.City = up.City AND g.Zip = up.Zip AND g.Country = up.Country) OR g.Home = 0) AND ((Age BETWEEN g.Maximum AND g.Minimum) OR g.Age = 0) AND ((SQRT(POW(69.1 * (g.Latitude - -93.5746359) , 2) + POW(69.1 * (44.9737707 - g.Longitude) * COS(g.Latitude/57.3) , 2)) > g.Distance) OR g.Geo = 0)) OR g.Special = 0)
GROUP BY qt.QID
我已經跑通過C#這個表達式,它返回真,但它僅在通過MySQL中「g.Special = 0」的部分進行匹配。
任何幫助,將不勝感激!