SQL - 左连接问题

Tom*_*Tom 4 sql sql-server

SELECT 
  tb1.booking_ref, tb1.investor, tb2.cost, tb3.product 
FROM 
  tb1, tb3 LEFT JOIN tb2 
ON
  tb1.booking_ref = tb2.booking_ref 
AND 
  tb1.investor = tb2.investor 
AND 
  tb1.investor = '12345'
WHERE
  tb1.location = tb3.location
Run Code Online (Sandbox Code Playgroud)

上面的查询错误是因为对tb3的引用 - 没有它们就很好用.

有谁有任何想法?

Joe*_*lli 7

SELECT 
  tb1.booking_ref, tb1.investor, tb2.cost, tb3.product
FROM 
  tb1
      inner join tb3
          on tb1.location = tb3.location
      left join tb2 
          on tb1.booking_ref = tb2.booking_ref
              and tb1.investor = tb2.investor 
WHERE tb1.investor = '12345'
Run Code Online (Sandbox Code Playgroud)