UNIT2(LABORATORY) Flashcards
insert into tbl_sample
values (‘juan’,143.44,1, 150.65);
iNSERTING ROWS
//SQL Server
insert into tbl_sample
values (‘juan’,143.44,null, 150.65);
//MySQL
insert into tbl_sample (s_name, s_amt, s_unit, s_price)
values (‘juan’,143.44,null, 150.65);
Inserting Rows with Null Attributes
insert into tbl_sample (s_name, s_amt)
values (‘juan’,143.44);
Inserting Rows with Optional Attributes
//SQL Server and MYSQL
select s_name, s_amt from tbl_sample;
select * from tbl_sample;
Select statements
//SQL Server and MYSQL
update tbl_sample
set s_amt = 255.20
where s_name = ‘juan’;
Update statements
//SQL Server and MYSQL
delete from tbl_sample
where s_name = ‘juan’;
Delete statements
INSERT INTO tablename SELECT columnlist FROM tablename
Inserting Rows from another table
insert into tbl_food(fd_name,fd_date) select ck_name,ck_date from tbl_cake;
//insert all data from tbl_Cake to tbl_Food
select fd_name,fd_date from tbl_food
where fd_name = ‘mocha’;
Select Queries
//SQL Server
select ck_name,ck_date from tbl_cake
where ck_date >= ‘1/1/2001’;
//MySQL
select ck_name,ck_date from tbl_cake where ck_date > ‘1990-1-1’;
Comparison Operators on Dates
//SQL Server and MySQL
select fd_name,fd_date,fd_price * fd_quantity as ‘total’ from tbl_food;
Computed Columns and Aliases
/SQL Server and MySQL/
select fd_name,fd_date from tbl_food
where fd_name = ‘choco’ and fd_date = ‘1994-10-23’;
Logical Operators: AND
/SQL Server and MySQL/
select fd_name,fd_date from tbl_food
where fd_name = ‘choco’ and fd_date = ‘1994-10-23’;
select fd_name,fd_date from tbl_food where fd_name = 'mocha' or (fd_name = 'choco' and fd_date = '1994-10-23');
Logical Operators: OR
/SQL Server and MySQL/
select fd_name,fd_date from tbl_food
where not(fd_name = ‘mocha’);
Logical Operators: NOT
/SQL Server and MySQL/
select * from tbl_food
where fd_price between 10 and 100;
The BETWEEN Special Operator