I have 2 tables.
Table one has:
has a VARCHAR id
table_1
+-----------------------------+
| ID | NAME | LOCATION |
+-----------------------------+
| A-5 | JOHN | A PLACE |
+-----------------------------+
table_2
+--------------+
| ID | VALID |
+--------------+
| A-5 | 1 |
+--------------+
I need to select all the information from table one if the ID in table 2 is valid (ie: valid=1).
Here is what I have so far, but it doesn't work. It selects all the information, but it sets the valid = 1 for EVERYTHING, no matter if it is 1 or 0 in the database to begin with. Can anyone help me with this?
SELECT DISTINCT c.id, c.name, c.location, d.valid FROM table_1 c, table_2 d WHERE d.valid = 1 AND c.id LIKE '%'