2

What is the proper syntax for a mysql-java statement such as this one ?

PreparedStatement st =connection.prepareStatement("SELECT Name, Value, Quantity FROM sales if (type=='Purchase' AND state=='confirmed') OR (type=='Sale' AND state=='not confirmed'))  ; 

2 Answers 2

1

The SQL would look like:

SELECT Name, Value, Quantity
FROM sales 
WHERE (type = 'Purchase' AND state = 'confirmed') OR
      (type = 'Sale' AND state = 'not confirmed');
Sign up to request clarification or add additional context in comments.

Comments

0

The condition should be in a where clause, not anifclause, and the equality check operator in SQL is=, not==`. So:

SELECT Name, Value, Quantity 
FROM   sales 
WHERe  (type = 'Purchase' AND state = 'confirmed') OR 
       (type = 'Sale' AND state = 'not confirmed')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.