1

If I have two parameter "parameterX" and "parameterY"

and I'll using "parameterX" and "parameterY" to commend sql snytax

like as

select * from test.test where 
IF(parameterY!=0)
 THEN test.test.'x'=parameterX AND test.test.'y'=parameterY 
ELSE IF
 test.test.'x'=parameterX 
END IF

I know this's can't work But I want to know have a other way like it and it can work in mysql

2 Answers 2

1

Or easier (than @diehud's answer):

select * from test.test where 
test.test.'x'=parameterX AND (test.test.'y'=parameterY OR parameterY=0)
Sign up to request clarification or add additional context in comments.

Comments

1

I think dont need use IF ELSE syntax

select * from test.test where 
(parameterY!=0 and test.test.'x'=parameterX AND test.test.'y'=parameterY)
OR (parameterY = 0 and test.test.'x'=parameterX )

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.