Reputation: 237
hi i am trying to join two tables using mysql query and for which i am unable to retriev the data
two tables are accountheader and accountheadermonths.
query:
Select ah.AH_SUBNAME,ahm.AH_OPENINGBALANCE1
from erp_updated.accountheader ah,erp_updated.accountheader_months ahm
where ah.AH_CODE =" " AND ahm.AH_CODE=" " ;
thanks in advance please help
Upvotes: 1
Views: 1618
Reputation: 21
In any join query, you have to specify the conditions which joins multiple tables. Looks like AH_CODE is the key which relates two tables in your case. So, query will be
SELECT
ah.AH_SUBNAME,
ahm.AH_OPENINGBALANCE1
FROM
erp_updated.accountheader ah,
erp_updated.accountheader_months ahm
WHERE
ah.AH_CODE=ahm.AH_CODE
AND ah.AH_CODE =" ";
Upvotes: 1
Reputation: 24116
For joining two tables you should have a common to join the two tables
Select ah.AH_SUBNAME,
ahm.AH_OPENINGBALANCE1
from erp_updated.accountheader ah
join
erp_updated.accountheader_months ahm
on ah.<col>=ahm.<col>
where ah.AH_CODE =" "
AND ahm.AH_CODE=" " ;
Upvotes: 4