2 ms·
Reading the title, I thought this was the actual question at hand. I try to keep JOIN logic to only on the keys. I like to think this makes reading the query m
by 0cf8612b2e1e 2y ago
Reading the title, I thought this was the actual question at hand.
I try to keep JOIN logic to only on the keys. I like to think this makes reading the query more linear: now I have all of these tables, what data gets retained/removed?
- inanutshellus 2y agoI see it as WHERE clause joining is the "can't mess it up" way to do it, and JOIN clause joining is "better in some situations". Imagine you're using SQL fragments. Using JOIN clauses make your code extremely clean: <sql id="getRecentReturns"> <fragment id="ReturnOrderFragment"> where returns.order_date between sysdate - 30 and sysdate <------- Nice, clean code. No chance bugs from forgetting to add `returns.order_type = "Return"` or `employee.customer_type = "Employee"` or whatever. </sql> That said - if the guy making the table didn't make an index that includes your attribute (order_type and customer_type above), don't use it."