I have two tables :
fields_col
---------------------
| id | type_field |
---------------------
| 1 | login |
| 2 | password |
| 3 | login |
| 4 | password |
value_field
----------------------------------
| id | typefieldid | value_field |
----------------------------------
| 1 | 1 | joe |
| 2 | 1 | doe |
| 3 | 4 | car |
| 4 | 3 | dom |
| 5 | 2 | he6 |
| 6 | 2 | abc |
| 7 | 3 | iph |
| 8 | 1 | nan |
| 9 | 4 | no9 |
I expect to get all values where the type is login
.
Here is the expected output :
joe
doe
dom
iph
nan
I made up the following query :
SELECT value_field
FROM value_field
WHERE typefieldid IN (SELECT id FROM fields_col WHERE type_field = "login")
And it output me the correct value.
I wonder how to use SQL join feature in this case.