-2

I have a SQLquery equal to is working but when I try to change and run as != its not working Please Help .

SELECT * FROM Database1 WHERE JobLevel IN != ('".$JobLevel_filter."')

I have to add not equal to query (!=) to job level .

user12031119
  • 1,228
  • 4
  • 14
  • 1
    Welcome to Stack Overflow! Please take the [tour] (you get a badge!), have a look around, and read through the [help], in particular [*How do I ask a good question?*](/help/how-to-ask) I also recommend Jon Skeet's [Writing the Perfect Question](https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) and [Question Checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). I'm afraid it's not at all clear what you're asking here. – T.J. Crowder Dec 15 '21 at 17:49
  • Separately, please be sure only to use appropriate tags. Your question has nothing whatsoever to do with [tag:jquery]. – T.J. Crowder Dec 15 '21 at 17:49
  • You have multiple issues with your syntax in your select statement. Get rid of the `IN` operator, get rid of the opening and closing parentheses `()` and change `!=` to `<>`. – user12031119 Dec 15 '21 at 19:17
  • @user12031119 `!=` and `<>` are the same thing https://dev.mysql.com/doc/refman/8.0/en/comparison-operators.html#operator_not-equal – Ergest Basha Dec 15 '21 at 19:21
  • You can't use both `IN` with `!=` . Maybe you mean `NOT IN` ? `!=` expect only one result – Ergest Basha Dec 15 '21 at 19:25
  • @ErgestBasha, that's fine, but my comment still takes a syntactically incorrect statement and makes it syntactically correct regardless if you change the not equal operator or not because the `IN` and `()` need to be removed. – user12031119 Dec 15 '21 at 19:28

1 Answers1

0

Try to use "<>" or "not like 'ABC'" instead of "!="

Thunk
  • 11
  • 2
  • [`!=`](https://dev.mysql.com/doc/refman/8.0/en/comparison-operators.html#operator_not-equal) is perfectly valid MySQL and standard SQL. – T.J. Crowder Dec 15 '21 at 18:01
  • @T.J.Crowder, `<>` alone is the ISO/ANSI - at least since SQL-92 (I have no older pdf, so I can't check SQL-89 until the next time I go to the office.) – jarlh Dec 15 '21 at 19:02
  • @jarlh - I guess I was misled by Wikipedia. But the fact remains that MySQL and [most others](https://stackoverflow.com/a/723426/157247) support it. – T.J. Crowder Dec 16 '21 at 07:16
  • @T.J.Crowder, I read customer code a couple of weeks ago where they still use `/=` for not equals to, and `!!` for concatenation. Old code never die. – jarlh Dec 16 '21 at 07:25