如何改写指定SQL查询语句以去除INNER JOIN关键字
Equivalent SQL Without INNER JOIN Keyword
Got it, here's the equivalent query that uses implicit joins (via the WHERE clause) instead of explicit INNER JOIN syntax—this will produce exactly the same result as your original query:
SELECT MAIN_ACCOUNTS.MAIN_ID, SUM(voucher.AMOUNT_US) "Total Amount" FROM MAIN_ACCOUNTS, SUB_ACCOUNTS, Voucher WHERE MAIN_ACCOUNTS.MAIN_ID = SUB_ACCOUNTS.MAIN_ID AND SUB_ACCOUNTS.SUB_ID = Voucher.credit_ACCOUNT_ID GROUP BY MAIN_ACCOUNTS.MAIN_ID;
Quick Breakdown
This is the traditional "old-school" join syntax: we list all the tables we need in the FROM clause, then define the relationships between them directly in the WHERE clause. It works exactly like your original INNER JOIN query—only rows where the matching IDs line up across all three tables are included, and we still group by MAIN_ID to calculate the total amount per main account.
内容的提问来源于stack exchange,提问作者Ahmed S. Elsenbawy
相关产品推荐
相关产品推荐

