Invoice reference against an order

Hi all,

Hope you guys are doing well, I am trying to export an invoice reference number against an order reference number. the link between both tables is done in this table llx_element_element.

I know I am doing something stupid by using a left join on these tables.

SELECT llx_facture.rowid,llx_facture.ref FROM llx_element_element
LEFT JOIN llx_element_element ON llx_element_element.fk_target = llx_facture.rowid
LEFT JOIN llx_element_element on llx_element_element.fk_source = llx_commande.rowid

Could anyone let me know how I can get the invoice reference number against all the order reference numbers?

with this MYSQL command, I am getting the following error.
#1066 - Not unique table/alias: 'llx_element_element’

Kind Regards,
Hafiz

Hello :slight_smile:

Check your sql command - you never use llx_facture and llx_commande
use this for example :
SELECT llx_facture.ref, llx_commande.ref FROM llx_facture
LEFT JOIN llx_element_element ON llx_element_element.fk_target = llx_facture.rowid
LEFT JOIN llx_commande on llx_element_element.fk_source = llx_commande.rowid

Good continuation