Reputation: 71
how to select rows not in where company=c and leg=2 without specific DB function
+---------+-----+
| company | leg |
+---------+-----+
| c | 1 |
| b | 2 |
| c | 2 |
| d | 1 |
+---------+-----+
and get:
+---------+-----+
| company | leg |
+---------+-----+
| a | 1 |
| b | 2 |
| d | 1 |
+---------+-----+
this is the typical wrong way:
SELECT *
FROM mytable
WHERE company <> 'c' AND leg <> 2
Upvotes: 1
Views: 56
Reputation: 311018
You could simply place these two conditions in the where
clause:
SELECT *
FROM mytable
WHERE company <> 'c' OR leg <> 2
Upvotes: 1
Reputation: 353
you can try this,
select company,leg from mytable where company !='c' OR leg !=2;
result:
+---------+-----+
| company | leg |
+---------+-----+
| c | 1 |
| b | 2 |
| d | 1 |
+---------+-----+
Upvotes: 0
Reputation: 32003
you can use not in
for company
SELECT *
FROM mytable where company not in ('c')
Upvotes: 0
Reputation: 1973
You can try this -
select company, leg
from table-name
where company != 'c'
and leg != 2
Upvotes: 0