Admitting out of the gate, I am a novice when it comes to SQL, so I am hoping someone can help me with this.
I am attempting to create a query that returns records based on a number of points of criteria.
I have two tables:
Table 1:
ElementID (PK)
ElementType
Table 2:
ValueID (PK)
Value Image (OLE object)
Lift (%)
Significant (yes/no)
Winner (yes/no)
Control (yes/no)
ElementID (FK)
Each element can have multiple values, so my tables have a 1 to many relationship. While each element can have multiple values, only 1 of those values can be considered to be the control (yes). Additionally, a control can never be considered significant.
I need my query to return ALL values that are significant (yes) + plus the control value that is associated with that element. But more importantly, if one of the elements does not have a significant value (no), do not show the corresponding control value. The problem I am having is the control value can never be considered significant, so the AND & the OR operators are not working because the query either returns nothing or everything.
Ex Table
ElementID | Element Type
1 | Header
2 | Button
3 | Text
ValueID | Value Image | Lift | Significant | Winner | Control | ElementID
1 | Image | 0.00% | No | No | Yes | 1
2 | Image | 5% | Yes | No | No | 1
3 | Image | 10% | Yes | Yes | No | 1
4 | Image | 0.00% | No | No | Yes | 3
5 | Image | 11% | No | Yes | No | 3
6 | Image | 1% | Yes | No | No | 3
I am attempting to create a query that returns records based on a number of points of criteria.
I have two tables:
Table 1:
ElementID (PK)
ElementType
Table 2:
ValueID (PK)
Value Image (OLE object)
Lift (%)
Significant (yes/no)
Winner (yes/no)
Control (yes/no)
ElementID (FK)
Each element can have multiple values, so my tables have a 1 to many relationship. While each element can have multiple values, only 1 of those values can be considered to be the control (yes). Additionally, a control can never be considered significant.
I need my query to return ALL values that are significant (yes) + plus the control value that is associated with that element. But more importantly, if one of the elements does not have a significant value (no), do not show the corresponding control value. The problem I am having is the control value can never be considered significant, so the AND & the OR operators are not working because the query either returns nothing or everything.
Ex Table
ElementID | Element Type
1 | Header
2 | Button
3 | Text
ValueID | Value Image | Lift | Significant | Winner | Control | ElementID
1 | Image | 0.00% | No | No | Yes | 1
2 | Image | 5% | Yes | No | No | 1
3 | Image | 10% | Yes | Yes | No | 1
4 | Image | 0.00% | No | No | Yes | 3
5 | Image | 11% | No | Yes | No | 3
6 | Image | 1% | Yes | No | No | 3