This is the data in the database
robot_id sequence_no x y
ABC1234E 1 8888 9999
ABC1234E 2 8888 9999
ABC1234E 3 8888 9999
ABC1234E 4 8888 9999
BBC1 1 8888 9999
BBC2 1 8888 9999
BBC2 2 8888 9999
BBC3 1 8888 9999
…..
I wish to exclude this resultset:
SELECT * FROM table WHERE robot_id=ABC1234E AND sequence_no='1'
This is what I should get:
robot_id sequence_no x y
ABC1234E 2 8888 9999
ABC1234E 3 8888 9999
ABC1234E 4 8888 9999
BBC1 1 8888 9999
BBC2 1 8888 9999
BBC2 2 8888 9999
BBC3 1 8888 9999
…..
robot id and sequence_no are the primary keys in this table
Just for the fun of it, you can also use the (ANSI standard)
exceptclause (minusin Oracle) which kind of “resembles” the way you asked the question:This will probably be slower than the other solutions though – but I thought I’d include it for completeness.
(Note that character literals have to be enclosed in single quotes and numbers don’t – just the other way round as you did in your question)