Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Syntax issue (left join)

So I'm having a problem with a query, and I don't really understand where. A comment is placed where the syntax error is. The query is much larger, I tried to shorten it to make a valid but tidier query.

This is using odbc to connect to a Progress database. I'm told it uses strict SQL-92.

SELECT itemcust."item-cust", 
       itemcust."cust-no", 
       corptreeCust.code 

FROM      pub."item-cust" itemcust 
JOIN      pub.customer cust 
left join pub.salesstructcustomer struct 
     on ( struct."corp-cust-type" = cust."corp-cust-type" 
      and struct."corp-cust-num" = cust."corp-cust-num" 
     ) 
left join pub.corptree corptreeCust 
      on ( corptreeCust.uid = struct.corptreeid /* program says SQL Syntax error here */
       and corptreeCust.category = 'store' 
      ) 

where ( itemcust."in-entity" = {$entity} or itemcust."in-entity" = '*') 
  and itemcust."item-no" = {$itemno} 
  and ( itemcust."cust-no" = {$custno} or itemcust."cust-no" = '*') 
  and cust."cust-no" = {$custno}

Thanks!

like image 414
corsiKa Avatar asked Sep 24 '26 04:09

corsiKa


2 Answers

Your table alias for pub.salesstructcustomer is struct, not structc as referenced in the join.

like image 51
Joe Stefanelli Avatar answered Sep 26 '26 18:09

Joe Stefanelli


Is that a typo? Looks like it's looking at structc instead of struct, unless I missed something.

like image 45
Onite Avatar answered Sep 26 '26 18:09

Onite