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 WH开发者_JAVA技巧ERE
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
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]')
";
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
精彩评论