Questions tagged [notin]

The NOT IN predicate acts opposite to the "IN" predicate. It can be used to specify multiple values that should NOT be present in a WHERE clause. Note that NOT IN never is true!

NOT Logical Operator

If you want to find rows that do not satisfy a condition, you can use the logical operator NOT. NOT results in the reverse of a condition. That is, if a condition is satisfied, then the row is not returned.

NOT IN can be represented as conjunction of NOT equal comparison operators.

A NOT IN (B, C) <=> (NOT A=B) AND (NOT A=C) If one of A or B is NULL, then NOT IN is not True (Undefined)

MSSQL NOT

IN Predicate

The IN predicate is used when you want to compare a column with more than one value. It is similar to a number of equals comparisons OR-ed together.

MSSQL IN Clause

308 questions
-1
votes
3 answers

Transform line-by-line values from another table to a string and insert it into NOT IN clause in SQL

I am trying to exclude a series of test users from 'test_user' table by using NOT IN. I got another 'member' table with userID and other information Originally, the tester user table is not too long, so people use NOT IN clause to exclude test…
Ryan
  • 3
  • 2
-1
votes
2 answers

MySQL "NOT IN" unexpected behavior when LEFT JOIN WITH null results

I have an app that receives an object and generates a dynamic query for gathering reporting data. That object contains filter properties that eventually translate into "WHERE" statements in MySQL. A simpler and on topic version of the generated…
Ovy.Istrate
  • 474
  • 3
  • 15
-1
votes
2 answers

MySQL: How do you query on a compound-primary-key? Specifically, a NOT IN query?

I have a comment table and a comment_edit table, as well as olddb_edit. Simplified, the relevant table looks like this: CREATE TABLE `olddb_edit` ( edit_id INT NOT NULL, edit_time INT NOT NULL, edit_text TEXT NOT NULL, PRIMARY KEY…
WoodrowShigeru
  • 1,418
  • 1
  • 18
  • 25
-1
votes
1 answer

Not Exists giving zero rows

I have read many answers related to this and all are saying both works almost same except in the case of null values ,and not in works for a single column. The task is to find each account number that has never been assigned to any line item in…
Brijesh Joshi
  • 19
  • 1
  • 10
-1
votes
1 answer

What do I need in my query, perhaps NOT EXISTS or NOT IN?

I have a table called review: review_id cat_id public_or_private 1 1 0 11 2 2 12 3 1 13 4 2 14 5 2 And a table called…
CHarris
  • 2,693
  • 8
  • 45
  • 71
-1
votes
1 answer

Count union of two table that has subquery

I have this working query. It has count with subquery. SELECT COUNT(*) AS total FROM (SELECT COUNT(aset) FROM `public_1` WHERE `public_1`.`aset` NOT IN (SELECT asset_code FROM application_detail WHERE…
sg552
  • 1,521
  • 6
  • 32
  • 59
-1
votes
3 answers

Insert row if there isn't already a row with the same id and url (two column values)

I would like to write a SQL statement that inserts a new row into the database if there isn't already a row for it. The unique identifier of a row is the id and url. Let's say the table schema looks like this: LinkClicks: (id, url, clicks) So now…
Captain Stack
  • 3,572
  • 5
  • 31
  • 56
-1
votes
2 answers

How to use NOT IN in SQL?

Game(p1, p2, pointsp1, pointsp2, ), Participant(name, club, age) FK Game(p1) references Participant(name), FK Game(p2) references participant(name) This is my relational schema and I am trying to return the list of names of participants who…
-1
votes
2 answers

"NOT IN" in HQL

I´m starting with Hibernate. I have 2 tables in MySQL DB. 1)Unit 2)type: has as foreign key Unit_IdUnit I have also in type a column name "Period" VARCHAR I want to create this query on HQL: SELECT * FROM unit WHERE IdUnit not in(SELECT…
Clams
  • 61
  • 1
  • 11
-1
votes
2 answers

Query depends on another query inside

I having a problem with a query inside another one. One table as question and the other one has que questions used by the users. So I'm Trying to query a new question but only if is not in the used question table. In this example looks like its…
Agent_x
  • 84
  • 2
  • 7
-1
votes
1 answer

SQL query command using and and not in clausing, a bit complicated one, lost at last step

EMPLOYEE (fname, minit, lname, ssn, birthdate, address, sex, salary, superssn, dno) KEY: ssn DEPARTMENT (dname, dnumber, mgrssn, mgrstartdate) KEY: dnumber. PROJECT (pname, pnumber, plocation, dnum) KEY: pnumber. WORKS_ON (essn, pno, hours) KEY:…
Lin Wei
  • 87
  • 1
  • 5
-1
votes
4 answers

MySQL Not In Not Working

I am working on putting a MySQL statement together and am wondering what the problem is with it. Why doesn't this MySQL statement work? SELECT * FROM `deals` WHERE CATEGORY NOT IN 'Construction & Repair' AND ( EXPIRE_DATE >= NOW() OR…
Daniel Harris
  • 1,805
  • 10
  • 45
  • 63
-2
votes
1 answer

Show null values from a set of rows if I DON'T know the value?

So background is clientnumber is value that client sent to me and will be inserted into the database. But so the 3 numbers above aren't inserted in the database by me YET, so it will turn blank when I search them in database. Is there way for SQL to…
-2
votes
1 answer

Return row in SQL that returning null value? to show them not as blank value

select * from dataentry with (nolock) where clientnumber in ( '00602', '00897', '00940' ) So background is clientnumber is value that client sent to me and will be inserted into the database. But so the 3 numbers above aren't inserted in the…
-2
votes
2 answers

Python dictionary, how can I create a key with a string and the actual key combined?

I hope this is a quite easy question, but for me without a lot of python background I can't find an answer. df = pd.DataFrame( {'Messung': ['10bar','10bar','10bar','20bar','20bar'], 'Zahl': [1, 2, 3, 4, 5], 'Buchstabe':…
Rabinzel
  • 7,757
  • 3
  • 10
  • 30
1 2 3
20
21