create database collage;
use collage;
create database if not exists collage_emp;
show databases;
create database if not exists collage;
show databases;
drop database collage_emp;
drop database if exists collage_temp;
create table student(roll int, name varchar(50), address text, coures varchar(50));
create table if not exists student_temp(roll int, name varchar(50), address text, coures varchar(50));
create table student_backup as select *from student_temp;
drop table student_temp;
drop table if exists student_temp;
drop table if exists student_backup;
alter table student add phone int;
alter table student add country varchar(50);
alter table student rename column roll to id;
alter table student modify column coures varchar(10);
alter table student drop column country;
alter table student rename to student_data;
select *from student_data;
insert into student_data (id, name, address, coures, phone) values (1, "dony", "india", "BAF",
09875677);
select *from student_data;
insert into student_data values(2, "mick", "chicango", "It", 8797865);
insert into student_data(id, name, phone) values (1, "sam", 9876789);
insert into student_data (id, name, address, coures, phone)
values
(3, "jessy", "island", "saas", 657843),
(4, "don", "china", "CS", 78659),
(5, "seereene", "america", "Bcom", 690865),
(6, "amit", "south china", "AI", 234156);
AND, OR, NOT, COMBINE OPERATOR
create database bussiness;
use bussiness;
create database if not exists bussiness;
create table customer(cust_id int, frist_name varchar(50), last_name varchar(50), age int, country
varchar(50));
create table if not exists customer(cust_id int, frist_name varchar(50), last_name varchar(50), age
int, country varchar(50));
insert into customer(cust_id, frist_name, last_name, age, country)
values
(1, "John", "Doe", 31, "USA"),
(2, "Robert", "Luna", 22, "USA"),
(3, "Dovid", "Robinson", 22, "UK"),
(4, "John", "Reinhardt", 25, "UK"),
(5, "Betty", "Deo", "28", "UAE");
select *from customer;
select frist_name, last_name from customer where country = "USA" AND last_name = "Deo";
select frist_name, last_name from customer where country = "USA" OR last_name = "Deo";
select *from customer where NOT country = "USA";
select *from customer where(country = "USA" OR country = "UK") AND age < 26;
select *from customer where NOT country = "USA" AND NOT last_name = "Deo";
SELECT STATEMENT
select frist_name from customer;
select frist_name, last_name from customer;
select *from customer;
select *from customer where last_name = "Deo";
select age, country from customer where country = "USA";
-- sql operator
select *from customer where frist_name = "John";
select *from customer where age > 25;
DISTINCT
select distinct age from customer;
select distinct country from customer;
select distinct frist_name, country from customer;
select count(distinct country) from customer;