[Solved] What join should I use with MySQL? [closed]


There are a few small mistakes in your query. In the ‘From’ section you only need to use the first table, and you’ll need to tell the join which field from the first table matches which field in the second table. In the where you’ll only have to match one field to $savingsId

This query should probably work:

SELECT Savings_Allocation.Bank,Savings_Allocation.TotalAmt,Savings_Allocation.Interest,Savings.Type,Savings.Access
FROM Savings_Allocation
INNER JOIN Savings ON Savings.savingsId = Savings_Allocation.savingsId
WHERE Savings.savingsId = '$savingsId'

Now the query above has one last flaw: using a variable inside a query string is unsafe and makes the query prone to SQL injection. So please read PHP’s guide on SQL injection on how to make a safe query. And don’t use mysql_query as it’s deprecated since php 5.5 and even removed in PHP 7. It’s recommeded to use mysqli or PDO instead.

solved What join should I use with MySQL? [closed]