10 Most Commonly Asked DA Interview Questions and Answers
10 Most Commonly Asked DA Interview Questions and Answers
2. What is the difference between INNER JOIN and LEFT JOIN in SQL?
Answer:
- INNER JOIN: Returns only the rows where there is a match in both tables.
- LEFT JOIN: Returns all the rows from the left table and the matched rows from the right
table. If there is no match, the result is NULL for the columns from the right table.
Example:
```sql
-- Inner Join
SELECT a.name, b.order_date
FROM customers a
INNER JOIN orders b ON a.customer_id = b.customer_id;
-- Left Join
SELECT a.name, b.order_date
FROM customers a
LEFT JOIN orders b ON a.customer_id = b.customer_id;
```