MySQL LEFT JOIN with DISTINCT or LIMIT. Need to LEFT JOIN only one value -
mysql table 18_8_chartofaccounts
accountnumber | vatreturnrownumberfordebitturnover ------------------------------------------- 1 | 61 2 | 55
mysql table 2_1_journal
debitaccount | transactionpartnername | amount ----------------------------------------------- 1 | name1 | 55 2 | name2 | 60
mysql table 18_6_transactionpartners
companyname ------------------------------- name1 name2 name1
query
select accountnumber, debitaccount, transactionpartnername, amount, companyname 18_8_chartofaccounts left join 2_1_journal on accountnumber = debitaccount left join 18_6_transactionpartners on transactionpartnername = companyname vatreturnrownumberfordebitturnover = '61' , amount = 55
in output necessary this
transactionpartnername | amount ----------------------------------------- name1 | 55
however in table 18_6_transactionpartners
there 2 names name1
get
transactionpartnername | amount ----------------------------------------------- name1 | 55 name1 | 55
instead of select
tried select distinct
(the same result).
instead of on transactionpartnername = companyname
tried on transactionpartnername = companyname limit 1
(get syntax error).
may need group companyname
somewhere.
please, advice...
try this:
select transactionpartnername, amount 18_8_chartofaccounts left join 2_1_journal on accountnumber = debitaccount left join 18_6_transactionpartners on transactionpartnername = companyname vatreturnrownumberfordebitturnover = '61' , amount = 55 group transactionpartnername;
Comments
Post a Comment