Get rows which do have references to list of values and at the same time don't have any references to list of other values

kerby

I am sure it was asked before but I just can't figure out how to search for it

I have a table table1:

| RefId_1 | RefId_2 |
---------------------
|       1 |     133 |
|       3 |      12 |
|       4 |     144 |
|       4 |      22 |
|       3 |     123 |

I need to get list of RefId_1 which do have reference to list of RefId_2 but don't have any references to another list of RefId_2.

For example, I need list of RefId_1 which references to RefId_2 list of (133, 22, 44) but such RefId_1 should not have references to list of RefId_2 (12, 144, 111).

Result should be just (1) because (4) references to forbidden 144

Thanks in advance

Youness

UPDATED : (UNTESTED)

SELECT DISTINCT REF_ID1 FROM table1 
    WHERE REF_ID2 IN(133,22,44)
    AND
    REF_ID1 NOT IN 
              (SELECT REF_ID1 FROM table1 WHERE REF_ID2 IN (12, 144, 111))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Find all rows with with values from list and which all have the same id MYSQL

From Dev

How do I get rows which have multiple values on the other column in sql server?

From Dev

How to get a list of rows that have the same Id but different values in the same field

From Dev

How do I get a list of .jpg files which don't have a matching .pdf?

From Dev

How can a List<Long> references to an ArrayList which has BigInteger values

From Dev

How to get all the rows from MySQL table which have same values for multiple columns?

From Dev

finding rows which don't have NA in a particular column if it already didn't have any NA

From Dev

Extract lines in CSV file which don't have elements in a list

From Dev

Extract lines in CSV file which don't have elements in a list

From Dev

List files that don't have any extension using command `dir`

From Dev

Pandas Dataframe from Dict key and list of values to have same key for multiple rows

From Dev

Pandas how to get a list of rows that have multiple values for an index level in a Multiindex DataFrame

From Dev

Pandas how to get a list of rows that have multiple values for an index level in a Multiindex DataFrame

From Dev

Have a list, need a DataFrame to use `loc` to lookup rows by column values

From Dev

In Cocoa under ARC can I get a list of objects that have references to another object (either programmatically or using Instruments)?

From Dev

T-SQL - Get a list of all As which have the same set of Bs

From Dev

Mysql - select rows which have linked values

From Dev

How do I have a form submit values to an ng-repeat list item that's on the same page?

From Dev

Dividing a list of numbers in two groups such that numbers in one group don't have any factor common with the numbers in the other group

From Dev

Get a list of directories or files I don't have permission to read

From Dev

Is there any formula for OpenCalc which can count rows that contain some values but do not contain other values?

From Dev

Get a list of all columns that do not have only NULL values in SQL Server

From Dev

Get a list of all columns that do not have only NULL values in SQL Server

From Dev

Combine tuples in a list which have the same value

From Dev

Values Don't Get Modified in Vector of List of Class

From Dev

Compare two excel files in Pandas and return the rows which have the same values in TWO columns

From Dev

Merge values of consecutive rows if they have the same values on a different column (AWK)

From Dev

Find rows that have same value in one column and other values in another column?

From Dev

MySQL - Return rows that don't have both values from two tables

Related Related

  1. 1

    Find all rows with with values from list and which all have the same id MYSQL

  2. 2

    How do I get rows which have multiple values on the other column in sql server?

  3. 3

    How to get a list of rows that have the same Id but different values in the same field

  4. 4

    How do I get a list of .jpg files which don't have a matching .pdf?

  5. 5

    How can a List<Long> references to an ArrayList which has BigInteger values

  6. 6

    How to get all the rows from MySQL table which have same values for multiple columns?

  7. 7

    finding rows which don't have NA in a particular column if it already didn't have any NA

  8. 8

    Extract lines in CSV file which don't have elements in a list

  9. 9

    Extract lines in CSV file which don't have elements in a list

  10. 10

    List files that don't have any extension using command `dir`

  11. 11

    Pandas Dataframe from Dict key and list of values to have same key for multiple rows

  12. 12

    Pandas how to get a list of rows that have multiple values for an index level in a Multiindex DataFrame

  13. 13

    Pandas how to get a list of rows that have multiple values for an index level in a Multiindex DataFrame

  14. 14

    Have a list, need a DataFrame to use `loc` to lookup rows by column values

  15. 15

    In Cocoa under ARC can I get a list of objects that have references to another object (either programmatically or using Instruments)?

  16. 16

    T-SQL - Get a list of all As which have the same set of Bs

  17. 17

    Mysql - select rows which have linked values

  18. 18

    How do I have a form submit values to an ng-repeat list item that's on the same page?

  19. 19

    Dividing a list of numbers in two groups such that numbers in one group don't have any factor common with the numbers in the other group

  20. 20

    Get a list of directories or files I don't have permission to read

  21. 21

    Is there any formula for OpenCalc which can count rows that contain some values but do not contain other values?

  22. 22

    Get a list of all columns that do not have only NULL values in SQL Server

  23. 23

    Get a list of all columns that do not have only NULL values in SQL Server

  24. 24

    Combine tuples in a list which have the same value

  25. 25

    Values Don't Get Modified in Vector of List of Class

  26. 26

    Compare two excel files in Pandas and return the rows which have the same values in TWO columns

  27. 27

    Merge values of consecutive rows if they have the same values on a different column (AWK)

  28. 28

    Find rows that have same value in one column and other values in another column?

  29. 29

    MySQL - Return rows that don't have both values from two tables

HotTag

Archive