I have three tables Patients, which contains the name of my patients, Controls which represents the UI controls which could be drawn for each illness , and ControlsValues table which contains the values of the controls submitted for each Patient
Lets have some data Patients Table
|ID | Name |
|-----------|
| 1 | Ara |
| 2 | Sada |
Controls table
|ID | Text | Type |
|-----------|----------|
| 1 | age | textbox |
| 2 |alergy| checkbox |
Then the controlsValues table which is where I want to query at
|ID | contrlId | value | patientId |
|---------------|----------|-----------|
| 1 | 1 | 23 | 1 |
| 2 | 2 | true | 1 |
| 3 | 1 | 26 | 2 |
| 4 | 2 | false | 2 |
here my problem occurs when I want to return that patient from ControlsValues
table that has the (controlId=1
AND value=23
) and (controlId=2
AND value=true
)
in this case the condition is on two rows not two columns which it is not possible , so I desided to change the rows into the columns depending on controlId
but I dont know how and I have been searching for 2 days and seen a lot of samples but none of them helped me to solve my problem
SELECT
you need.