JOIN DAN SUBQUERY (DML) - Xampp

 

1.    Seperti biasa Start Xampp Terlebih dahulu



2.    Selanjutkan Ke Windows > CMD

3.    lalu ketikkan perintah berikut

 

C:\Users\trijulian>cd c:\xampp\mysql\bin

c:\xampp\mysql\bin>mysql -u root -p

Enter password: (Kosongkan aja)

4.    Jika sudah maka tampilannya seperti berikut:

 


5.    Buatlah sebuah database dengan nama “Order_20071006”

create database order_20071006;

 

6.    Jika sudah, kitab isa lihat databases yang baru saja kita input seperti berikut

show databases;

 7.    Jika sudah kita gunakan order itu dengan cara berikut

use order_20071006;

 

8.     show tables;

 


9.     

 

MariaDB [order_20071006]> select products.prod_name,products.prod_price,vendors.vend_name,vendors.vend_address from products,vendors where vendors.vend_id=products.vend_id;

10.   

MariaDB [order_20071006]> select * from products,vendors where products.vend_id=vendors.vend_id;

 

 

11.   

 

MariaDB [order_20071006]> select products.prod_name,products.prod_price,vendors.vend_name,vendors.vend_address from products,vendors where vendors.vend_id=products.vend_id;

 

 

12.   

MariaDB [order_20071006]> select products.prod_name,products.prod_price,orderitems.quantity from products,orderitems where products.prod_id=orderitems.prod_id;



13.   

MariaDB [order_20071006]> select products.prod_name,products.prod_price,orderitems.quantity from products,orderitems where products.prod_id=orderitems.prod_id and orderitems.order_num=20005;

 


14.   

MariaDB [order_20071006]> select a.prod_name,a.prod_price,b.vend_name,c.quantity from products a,vendors b, orderitems c where a.prod_id=c.prod_id and b.vend_id=a.vend_id and c.order_num=20007;

 


15.   

MariaDB [order_20071006]> select a.prod_name,a.prod_price,b.vend_name,c.quantity from products a,vendors b, orderitems c where a.prod_id=c.prod_id and b.vend_id=a.vend_id;

 


 

16.   

MariaDB [order_20071006]> select a.prod_name, a.prod_price, b.vend_name

    -> from products a, vendors b

    -> where a.vend_id = b.vend_id;

 

 

 

17.   

MariaDB [order_20071006]> select a.prod_name, a.prod_price, b.vend_name, c.quantity

    -> from products a, vendors b, orderitems c

    -> where a.vend_id = b.vend_id and a.prod_id = c.prod_id;

 



 

Komentar