user1450954
user1450954

Reputation: 237

MySql Join Query two tables

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

Answers (2)

Nabin Hait
Nabin Hait

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

Joe G Joseph
Joe G Joseph

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

Related Questions