0

I want to create an SQL command in a MySQL/PHP environment where the NOT operator is used. I have created the following piece of code:

"SELECT software.*, FROM software,softwarever WHERE  
software.ID = softwarever.ID AND (software.ID='$_GET[text]' OR
software.Name='$_GET[text]') 
NOT(software.ID='$_GET[extra_text]' OR software.Name='$_GET[extra_text]')";

When I go and execute it however it gives me error due to the NOT operator. Does anyone knows if there is a solution to this? Thanks in advance!

P.S. I don't want the NOT IN operator

2 Answers 2

4

You need to put and AND or OR before your NOT, depending on your logic. And lose the comma after your SELECT. For exmaple:

"
SELECT software.*
FROM   software,softwarever 
WHERE  software.ID = softwarever.ID 
AND    (software.ID='$_GET[text]' OR software.Name='$_GET[text]') 
OR NOT (software.ID='$_GET[extra_text]' OR software.Name='$_GET[extra_text]')
";
Sign up to request clarification or add additional context in comments.

Comments

3

You're missing AND/OR before the NOT.

The query doesn't know if you want X AND NOT Y or X OR NOT Y

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.