I use DB2.
Situation: I want do do a query on my table RELATIONS to list ALL the companies that have a RELATION 1 AND a RELATION 2 OR 3 assigned. In my DB design, 1 or more companies could have multiple relations.
I want to do a select statement with multiple AND operators on the same column (RELATION) with SQL but if i execute the code i do not get any hits.
SELECT R_ID, COMPANY_NAME from RELATION
WHERE COMPANY_GROUP = 2245
AND RELATION = 1
AND RELATION in (2,3)
When i execute this i don't get any hits.
This is my DB design.
***This is the the table RELATION
R_ID, RELATION, COMPANY_NAME
121 1 Inbev
122 6 Jupiler
123 1 Unox
124 2` Unox
125 4 Lotus
126 1 Lu
127 1 Felix
128 2 Felix
129 1 Unicoresels
130 3 Unicoresels
131 4 Sporkamt
***This is the table COMPANY
COMPANY_ID, COMPANY_NAME, COMPANY_ADDRESS, COMPANY_GROUP
31 Jupiler Some address 2245
32 Unox Some address 2245
33 Lotus Some address 2245
34 Lu Some address 2245
35 Felix Some address 2245
36 Unicoresels Some address 2245
37 Sporkampt Some address 2245
This is the result i want to achieve with a query.
R_ID, COMPANY_NAME
123 Unox
124 Unox
127 Felix
128 Felix
129 Unicoresels
130 Unicoresels
How can i do this?