mysql-java语句的正确语法是什么,例如这个?
PreparedStatement st =connection.prepareStatement("SELECT Name, Value, Quantity FROM sales if (type=='Purchase' AND state=='confirmed') OR (type=='Sale' AND state=='not confirmed')) ;
答案 0 :(得分:1)
SQL看起来像:
SELECT Name, Value, Quantity
FROM sales
WHERE (type = 'Purchase' AND state = 'confirmed') OR
(type = 'Sale' AND state = 'not confirmed');
答案 1 :(得分:0)
如果where clause, not an
= clause, and the equality check operator in SQL is
==`,条件应为, not
。所以:
SELECT Name, Value, Quantity
FROM sales
WHERe (type = 'Purchase' AND state = 'confirmed') OR
(type = 'Sale' AND state = 'not confirmed')