Hello. I am having a problem getting my desired outcome with my table. Here is what I have.
Table: orders
+-------+-------+------+------+------+------+---------+
| ordno | month | cid | aid | pid | qty | dollars |
+-------+-------+------+------+------+------+---------+
| 1011 | jan | c001 | a01 | p01 | 1000 | 450 |
| 1012 | jan | c001 | a01 | p01 | 1000 | 450 |
| 1019 | feb | c001 | a02 | p02 | 400 | 180 |
| 1017 | feb | c001 | a06 | p03 | 600 | 540 |
| 1018 | feb | c001 | a03 | p04 | 600 | 540 |
| 1023 | mar | c001 | a04 | p05 | 500 | 450 |
| 1022 | mar | c001 | a05 | p06 | 400 | 720 |
| 1025 | apr | c001 | a05 | p07 | 800 | 720 |
| 1013 | jan | c002 | a03 | p03 | 1000 | 880 |
| 1026 | may | c002 | a05 | p03 | 800 | 704 |
| 1015 | jan | c003 | a03 | p05 | 1200 | 1104 |
| 1014 | jan | c003 | a03 | p05 | 1200 | 1104 |
| 1021 | feb | c004 | a06 | p01 | 1000 | 460 |
| 1016 | jan | c006 | a01 | p01 | 1000 | 500 |
| 1020 | feb | c006 | a03 | p07 | 600 | 600 |
| 1024 | mar | c006 | a06 | p01 | 800 | 400 |
+-------+-------+------+------+------+------+---------+
What I am trying to do is list only the entries from cid that have both 'p01' and 'p02' in the pid column.
In oracle(sqlplus) I did it like this:
select cid from orders where pid='p01'
intersect select cid from orders where pid='p02';
Thank you.
Table: orders
+-------+-------+------+------+------+------+---------+
| ordno | month | cid | aid | pid | qty | dollars |
+-------+-------+------+------+------+------+---------+
| 1011 | jan | c001 | a01 | p01 | 1000 | 450 |
| 1012 | jan | c001 | a01 | p01 | 1000 | 450 |
| 1019 | feb | c001 | a02 | p02 | 400 | 180 |
| 1017 | feb | c001 | a06 | p03 | 600 | 540 |
| 1018 | feb | c001 | a03 | p04 | 600 | 540 |
| 1023 | mar | c001 | a04 | p05 | 500 | 450 |
| 1022 | mar | c001 | a05 | p06 | 400 | 720 |
| 1025 | apr | c001 | a05 | p07 | 800 | 720 |
| 1013 | jan | c002 | a03 | p03 | 1000 | 880 |
| 1026 | may | c002 | a05 | p03 | 800 | 704 |
| 1015 | jan | c003 | a03 | p05 | 1200 | 1104 |
| 1014 | jan | c003 | a03 | p05 | 1200 | 1104 |
| 1021 | feb | c004 | a06 | p01 | 1000 | 460 |
| 1016 | jan | c006 | a01 | p01 | 1000 | 500 |
| 1020 | feb | c006 | a03 | p07 | 600 | 600 |
| 1024 | mar | c006 | a06 | p01 | 800 | 400 |
+-------+-------+------+------+------+------+---------+
What I am trying to do is list only the entries from cid that have both 'p01' and 'p02' in the pid column.
In oracle(sqlplus) I did it like this:
select cid from orders where pid='p01'
intersect select cid from orders where pid='p02';
Thank you.