SELECT salesmast.*,
ledgermast.ledgername AS Customer,
areamast.areaid,
areamast.areadesc,
LedgerMast_1.ledgername AS SalesLedger,
ledgermast.phone,
ledgermast.subareaid AS SubAreaID2,
ledgermast.salesmanid AS SalesmanID2,
salestypemast.salestypedesc,
salestypemast.salestypestatus,
( Iif(Isnull(salestypestatus), 'S', salestypestatus) & '/' &
Format(Val(
salesmast.invno), "00000") ) AS STDcNo,
tablesmast.tablecode,
ordertypemast.ordertypedesc,
operators.operatorname,
salesmanmast.salesmanname,
doctormast.doctorname
FROM (((((((salesmast
LEFT JOIN (ledgermast
LEFT JOIN areamast
ON ledgermast.areaid = areamast.areaid)
ON salesmast.customerledgerid = ledgermast.ledgerid)
LEFT JOIN ledgermast AS LedgerMast_1
ON salesmast.salesledgerid = LedgerMast_1.ledgerid)
LEFT JOIN salestypemast
ON salesmast.salestypeid = salestypemast.salestypeid)
LEFT JOIN tablesmast
ON salesmast.table_id = tablesmast.table_id)
LEFT JOIN ordertypemast
ON salesmast.ordertypeid = ordertypemast.ordertypeid)
LEFT JOIN operators
ON salesmast.operatorid = operators.operatorid)
LEFT JOIN salesmanmast
ON salesmast.salesmanid = salesmanmast.salesmanid)
LEFT JOIN doctormast
ON salesmast.doctorid = doctormast.doctorid;
What I have tried:
SELECT salesmast.*,
ledgermast.ledgername AS Customer,
areamast.areaid,
areamast.areadesc,
LedgerMast_1.ledgername AS SalesLedger,
ledgermast.phone,
ledgermast.subareaid AS SubAreaID2,
ledgermast.salesmanid AS SalesmanID2,
salestypemast.salestypedesc,
salestypemast.salestypestatus,
( Iif(Isnull(salestypestatus), 'S', salestypestatus) & '/' &
Format(Val(
salesmast.invno), "00000") ) AS STDcNo,
tablesmast.tablecode,
ordertypemast.ordertypedesc,
operators.operatorname,
salesmanmast.salesmanname,
doctormast.doctorname
FROM (((((((salesmast
LEFT JOIN (ledgermast
LEFT JOIN areamast
ON ledgermast.areaid = areamast.areaid)
ON salesmast.customerledgerid = ledgermast.ledgerid)
LEFT JOIN ledgermast AS LedgerMast_1
ON salesmast.salesledgerid = LedgerMast_1.ledgerid)
LEFT JOIN salestypemast
ON salesmast.salestypeid = salestypemast.salestypeid)
LEFT JOIN tablesmast
ON salesmast.table_id = tablesmast.table_id)
LEFT JOIN ordertypemast
ON salesmast.ordertypeid = ordertypemast.ordertypeid)
LEFT JOIN operators
ON salesmast.operatorid = operators.operatorid)
LEFT JOIN salesmanmast
ON salesmast.salesmanid = salesmanmast.salesmanid)
LEFT JOIN doctormast
ON salesmast.doctorid = doctormast.doctorid;