Skip to content

Commit beb251f

Browse files
committed
updating join queries
1 parent 570da1c commit beb251f

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,50 @@ group by month
157157
```
158158

159159
# Chapter 8 **JOIN**
160+
## INNER JOIN
161+
```
162+
select order_id, customer.customer_id, order_date, ship_date, name, street_address, street_Address, city, state, zip,product_id, order_qty
163+
from customer inner join customer_order
164+
on customer.CUSTOMER_ID= customer_order.CUSTOMER_ID;
165+
```
166+
## LEFT JOIN
167+
```
168+
select order_id, customer_id, order_date,
169+
ship_date, name, street_address, street_Address,
170+
city, state, zip,product_id, order_qty
171+
from customer LEFT join customer_order
172+
on customer.CUSTOMER_ID= customer_order.CUSTOMER_ID;
173+
```
174+
```
175+
SELECT ORDER_ID, CUSTOMER_ID,NAME
176+
FROM CUSTOMER LEFT JOIN CUSTOMER_ORDER
177+
ON CUSTOMER.CUSTOMER_ID = CUSTOMER_ORDER.CUSTOMER_ID
178+
WHERE ORDER_ID IS NULL;
179+
```
180+
## Other JOIN Types
181+
### RIGHT JOIN and OUTER JOIN
182+
Not featured in SQLite due to their highly niche nature.
183+
184+
## Joining Multiple Tables
185+
```
186+
SELECT ORDER_ID, customer.CUSTOMER_ID, name,
187+
street_address,city,state,zip,order_date,product_id,description, order_qty
188+
FROM CUSTOMER
189+
INNER JOIN CUSTOMER_ORDER
190+
ON CUSTOMER.CUSTOMER_ID = CUSTOMER_ORDER.CUSTOMER_ID
191+
INNER JOIN PRODUCT
192+
ON CUSTOMER_ORDER.PRODUCT_ID=PRODUCT.PRODUCT_ID ;
193+
```
194+
```
195+
SELECT ORDER_ID, customer.CUSTOMER_ID, name,
196+
street_address,city,state,zip,order_date,product_id,description, order_qty, ORDER_QTY*PRICE AS REVENUE
197+
FROM CUSTOMER
198+
INNER JOIN CUSTOMER_ORDER
199+
ON CUSTOMER.CUSTOMER_ID = CUSTOMER_ORDER.CUSTOMER_ID
200+
INNER JOIN PRODUCT
201+
ON CUSTOMER_ORDER.PRODUCT_ID=PRODUCT.PRODUCT_ID ;
202+
```
203+
## Grouping JOINs
204+
```
205+
206+
```

tempCodeRunnerFile.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define INF 999
4+
int V=8;
5+
int dist[8]={INF};
6+
7+
int main(){
8+
9+
return 0;
10+
}

tempCodeRunnerFile.exe

48.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)