Pacijent Pacijent - 1 year ago 52
SQL Question

SELECT columns EXCEPT values that are loaded from file

Let's say i have table


|1 |25 |a |
|2 |48 |a |
|3 |25 |b |
|4 |25 |d |
|5 |16 |e |

And i have command:

"SELECT Column1 FROM TABLE1 WHERE Column2 = 25)";

So now output is:


Now i want to do the same but if column3 = a, then do not select that row, so output is now:


And now i want A to be loaded from txt file, but in that file would be more values (a, b, d, g, u...)

So basicly i want to

SELECT [columns] FROM [table] WHERE [column1] = 1 EXCEPT [column2] = [values from txt]

I just need logic for command, i know everything other.

Answer Source

Add AND [column2] NOT IN [values from txt]:

SELECT [columns] FROM [table]
WHERE [column1] = 1 AND [column2] NOT IN  (a, b, d, g, u...)