I have a problem with my SQL query.
Situation is as follows:
I have two tables, A and B.
Table A:
---------------------------------------------
*| A.id | A.t_id | A.f_id | A.type |*
---------------------------------------------
| 1 | 32 | 3 | Loading |
| 2 | 34 | 5 | Discharge |
| 3 | 32 | 3 | Discharge |
---------------------------------------------
Table B:
-----------------------
*| B.id | B.shipid |*
-----------------------
| 1 | 1 |
| 2 | 1 |
| 3 | 2 |
-----------------------
I need all the rows from A where A.type=Loading, A.t_id is B.id -> B.shipid=2 and . My query so far is:
SELECT * FROM A, B WHERE (A.type='Loading' AND B.shipid=2 AND A.t_id=B.id)
but this doesn’t return the right records (none, actually) while the data should fit the query. Where does my query goes wrong?
Try this::