NOT EXISTS works like EXISTS, except the WHERE clause in which it is used is satisfied if no rows are returned by the subquery.
Questions tagged [not-exists]
403 questions
7
votes
3 answers
Not Exists using Linq
sorry for my english, I'll try to be short and concise.
I have to tables "ALUMNOS" and "MATERIAS". In SQL exist another table "ALUMNOS BY MATERIAS". I know this is not necessary in EF because exists the properties navigation, but I need to get the…

Guille
- 115
- 1
- 1
- 7
7
votes
2 answers
COUNT() Function in conjunction with NOT IN clause not working properly with varchar field (T-SQL)
I came across a weird situation when trying to count the number of rows that DO NOT have varchar values specified by a select statement. Ok, that sounds confusing even to me, so let me give you an example:
Let's say I have a field "MyField" in…

The Shaper
- 3,495
- 2
- 16
- 6
7
votes
3 answers
Trying to delete when not exists is not working. Multiple columns in primary key
I am currently trying to delete from Table A where a corresponding record is not being used in Table B. Table A has Section, SubSection, Code, Text as fields, where the first three are the Primary Key. Table B has ID, Section, SubSection, Code as…

user2958704
- 71
- 1
- 1
- 2
6
votes
2 answers
Mysql: Perform of NOT EXISTS. Is it possible to improve perfomance?
I have two tables posts and comments. Table comments have post_id attribute. I need to get all posts with type "open", for which there are no comments with type "good" and created date MAY 1.
Is it optimal to use such SQL-query:
SELECT posts.*…

petRUShka
- 9,812
- 12
- 61
- 95
5
votes
2 answers
Magento: addAttributeToFilter but ignore for products that don't have this attribute?
I'm trying to show add some filters on my store, but they have a nasty side effect.
Suppose I have product type A and B. Now I want to only show A where color = blue/red.
$collection = Mage::getResourceModel('catalog/product_collection')
…

Rakward
- 1,657
- 2
- 18
- 24
5
votes
2 answers
check if a key exist firebase Android
I want to check if a key exist in the firebase db. so for example, I want to look for the key "upvotes" to see if it exist or not.
Here is an exmaple, "upvotes" key does not exist in here:
Now I my attempt to check if the key "upvotes" is at this…

nothingness
- 694
- 3
- 9
- 25
5
votes
3 answers
select non-duplicated records
I have a table with about 50 millions records.
the table structure is something like below and both callerid and call_start fields are indexed.
id -- callerid -- call_start
I want to select all records that their call_start is greater than…

Mehdi
- 661
- 5
- 17
5
votes
1 answer
Key "path" for array with keys "" does not exist while dump says it does
I'm currently working on a cms using symfony2 as the underlying framework and twig as the template engine.
My problem is the following:
While this
{% for image in images %}
{{ dump(image.path is defined) }}
{% endfor %}
returns true for each…

Markus Kottländer
- 8,228
- 4
- 37
- 61
5
votes
4 answers
SQL: UPDATE if not exists, else DELETE
I'm currently trying to write a script that will change a user's role to another, without creating duplicates in a SQL Server database.
For example:
User_ID Role_ID
---------------------
A X
A Z
B Y
C …

Viprus
- 153
- 1
- 6
5
votes
3 answers
SQL: INNER JOIN + NOT EXIST
I am trying to create an SQL statement where I need to join 3 tables
EnrollStudents
EnrollID UserID SubjID
1 1 1
2 1 2
3 1 3
4 3 1
5 7 …

abramlimpin
- 5,027
- 11
- 58
- 97
3
votes
2 answers
MS Access SQL Query Not Exist
I have been stuck on trying to figure how to return data that is in one table but not the other. I thought an outter join would work, but it seems that Access does not allow that.
My SQL is returning results if a record exists in the…

Tom
- 77
- 10
3
votes
0 answers
Missing files when publishing using folder profile in VS 2019
When I publish a new web app (started in VS 2019) to a folder on the intranet (using a "folder profile"), not all files are published.
If I don't use the pre-compile option, I don't get any publish errors, but files are missing when I access the…

Bert Sirkin
- 53
- 5
3
votes
1 answer
Django migration dependencies reference nonexistent parent node
I have a problem with django migrations. I get this error:
django.db.migrations.exceptions.NodeNotFoundError: Migration user.0050_merge_20170523_1254 dependencies reference nonexistent parent node ('user', '0049_auto_20170519_1934')
I fix the…

GIA
- 1,400
- 2
- 21
- 38
3
votes
2 answers
SQL: Select Duplicate Values using Distinct, Not Exists, CTE, Union
I need to select duplicate values highlighted in green from the Object table show below:
I've tried different combination of the code below. But cannot return the two duplicate rows.
;with CTE as
(Select distinct ID, count([Object ID]) as…

Data Engineer
- 795
- 16
- 41
3
votes
1 answer
MySQL Insert query failing
I'm using backand.com to make a query that attempts to create a record in a users table if the email isn't already used:
INSERT INTO users (email, firstName, lastName, password)
SELECT * FROM (SELECT '{{email}}', 'test', 'person', '{{password}}') AS…

Dave
- 5,283
- 7
- 44
- 66