In [1]:
show databases
Database
company
information_schema
raj
In [2]:
use raj
yes
In [6]:
select distinct id, name from CUSTOMERS where age > 30;
id name
1 Ramesh
8 Raj
In [5]:
select count(id)
from   CUSTOMERS;
count(id)
8
In [7]:
select count(oid) from orders
count(oid)
20
In [12]:
select count(oid)
from   CUSTOMERS, ORDERS
where  id = customer_id and name = 'kaushik';
count(oid)
7
In [13]:
select sum(amount)
from   CUSTOMERS, ORDERS
where  id = customer_id and name = 'kaushik';
sum(amount)
16960
In [14]:
select *
from   CUSTOMERS, ORDERS
where  id = customer_id and name = 'kaushik';
ID NAME AGE ADDRESS SALARY oid date customer_id amount
3 kaushik 23 Kota 2000.00 100 2009-10-08 00:00:00 3 1500
3 kaushik 23 Kota 2000.00 102 2009-10-08 00:00:00 3 3000
3 kaushik 23 Kota 2000.00 104 2010-10-07 00:00:00 3 500
3 kaushik 23 Kota 2000.00 106 2011-10-18 00:00:00 3 3200
3 kaushik 23 Kota 2000.00 112 2012-10-08 00:00:00 3 1000
3 kaushik 23 Kota 2000.00 115 2012-10-10 00:00:00 3 7560
3 kaushik 23 Kota 2000.00 116 2012-10-18 00:00:00 3 200
In [17]:
select max(salary)
from   customers;
max(salary)
80000.00
In [19]:
select count(oid)
from   CUSTOMERS, ORDERS
where  id = customer_id and
       name = 'Hardik';
count(oid)
6
In [32]:
select name
from   customers, orders
(1054, "Unknown column 'name' in 'field list'")
In [25]:
select id IDD 
from customers;
IDD
1
2
3
4
5
6
7
8
In [33]:
show databases
Database
company
information_schema
raj
In [35]:
show databases
Database
company
information_schema
raj
In [36]:
show databases
Database
company
information_schema
raj
In [ ]: