1
SELECT * FROM event JOIN user ON event.event_user_id=user.user_id
WHERE ((event.event_date BETWEEN '2011-03-01' AND '2011-04-01')
AND user.user_id in (SELECT user_id FROM user_map
WHERE (user_map.user_id_map=1 AND user_map.user_relation<=7)));
蟾蜍/ MySQL的這是工作正常,但失敗時,我在Java + MySQL驅動程序準備好的聲明中做得一樣哪些錯誤與此MySQL查詢
SELECT * FROM event JOIN user ON event.event_user_id=user.user_id
WHERE ((event.event_date BETWEEN ? AND ?)
AND user.user_id in (SELECT user_id FROM user_map
WHERE (user_map.user_id_map=? AND user_map.user_relation<=?)));
...
pstmt.setDate(1, <sqlDate>);
pstmt.setDate(2, <sqlDate>);
pstmt.setLong(3, <int>);
pstmt.setLong(4, <int>);
pstmt.executeQuery();
指標「失敗」非常含糊......謹慎告訴我們究竟發生了什麼?它執行但返回錯誤的結果嗎?提供錯誤訊息?如果是後者,那麼錯誤信息是什麼? – 2011-03-18 06:27:35
顯示堆棧跟蹤。 – Nishant 2011-03-18 06:33:14
當你最後的代碼片段發佈時,它也會很有用。有些錯誤可以通過將參數傳遞給準備陳述方法來完成,我們無法通過依次檢查實際參數等等。 –
Chris
2011-03-18 08:23:26