UNIT2(LABORATORY) Flashcards

1
Q

insert into tbl_sample
values (‘juan’,143.44,1, 150.65);

A

iNSERTING ROWS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

//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);

A

Inserting Rows with Null Attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

insert into tbl_sample (s_name, s_amt)
values (‘juan’,143.44);

A

Inserting Rows with Optional Attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

//SQL Server and MYSQL
select s_name, s_amt from tbl_sample;
select * from tbl_sample;

A

Select statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

//SQL Server and MYSQL
update tbl_sample
set s_amt = 255.20
where s_name = ‘juan’;

A

Update statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

//SQL Server and MYSQL
delete from tbl_sample
where s_name = ‘juan’;

A

Delete statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

INSERT INTO tablename SELECT columnlist FROM tablename

A

Inserting Rows from another table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

insert into tbl_food(fd_name,fd_date) select ck_name,ck_date from tbl_cake;

A

//insert all data from tbl_Cake to tbl_Food

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

select fd_name,fd_date from tbl_food
where fd_name = ‘mocha’;

A

Select Queries

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

//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’;

A

Comparison Operators on Dates

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

//SQL Server and MySQL
select fd_name,fd_date,fd_price * fd_quantity as ‘total’ from tbl_food;

A

Computed Columns and Aliases

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

/SQL Server and MySQL/
select fd_name,fd_date from tbl_food
where fd_name = ‘choco’ and fd_date = ‘1994-10-23’;

A

Logical Operators: AND

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

/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');
A

Logical Operators: OR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

/SQL Server and MySQL/
select fd_name,fd_date from tbl_food
where not(fd_name = ‘mocha’);

A

Logical Operators: NOT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

/SQL Server and MySQL/
select * from tbl_food
where fd_price between 10 and 100;

A

The BETWEEN Special Operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

/SQL Server and MySQL/
select * from tbl_food
where fd_name is null;

A

The IS NULL Special Operator

17
Q

the following query would find all fd_name rows that has the letter ‘o’

A

select * from tbl_food
where fd_name like ‘%o%’

18
Q

The following query would find all fd_name rows that has any letter in between ‘ch’ and ‘co’ such as ‘chaco’, ‘ chbco’, etc.

A

select * from tbl_food
where fd_name like ‘ch_co’

19
Q

The following query would find all fd_name rows that has any letter in between a, e, i, o, u such as ‘choca’, ‘choce’, ‘choci’, ‘choco’, ‘chocu’ etc.

A

/SQL Server/
select * from tbl_food
where fd_name like ‘choc[aeiou]’

/Mysql/
select * from tbl_food
where fd_name REGEXP ‘choc[aeiou]’

20
Q

The following query would find all fd_name rows that has any letter EXCEPT a, e, i, o, u in between such as ‘chocb’, ‘chocc’, ‘chocd’, ‘chocf’, ‘chocg’ etc.

A

/SQL Server/
select * from tbl_food
where fd_name like ‘choc[^aeiou]’

/Mysql/
select * from tbl_food
where fd_name REGEXP ‘choc[^aeiou]’

21
Q

/SQL Server and MySQL/
select * from tbl_food
where fd_name in (‘choco’,’mocha’);

A

The IN Special Operator

22
Q

select * from tbl_cake
where exists (select fd_name from tbl_food where fd_price > 5);

A

The EXISTS Special Operator