Você está na página 1de 6

1.

mysql> select stu_fname, stu_lname, stu_notes


-> from student
-> where stu_id=3;
+-----------+-----------+------------------+
| stu_fname | stu_lname | stu_notes

+-----------+-----------+------------------+
| Max

| Starton | dont play sports |

+-----------+-----------+------------------+
1 row in set (0.00 sec)

2.
mysql> select act_id, act_name, act_cost, act_notes, concat('$',
format(act_cost,2))
-> from activity
-> order by act_cost desc;
+--------+----------+----------+-----------+---------------------------------+
| act_id | act_name | act_cost | act_notes | concat('$',
format(act_cost,2)) |
+--------+----------+----------+-----------+---------------------------------+
|

10 | Lauren |

9 | Sally

6 | Sam

7 | Daphne |

8 | Sara

51.12 | NULL
22.41 | NULL

22.22 | NULL
21.11 | NULL
20.11 | NULL

| $51.12
| $22.41
| $22.22

|
|
|

| $21.11
| $20.11

|
|

+--------+----------+----------+-----------+---------------------------------+
5 rows in set (0.01 sec)

3.

mysql> select stu_lname, stu_fname, act_name,act_cost, stu_notes,


concat('$', format (act_cost,2))
-> from student,activity;
+-----------+-----------+----------+----------+-----------------+----------------------------------+
| stu_lname | stu_fname | act_name | act_cost | stu_notes
concat('$', format (act_cost,2)) |

+-----------+-----------+----------+----------+-----------------+----------------------------------+
| Smith
|

| Sam

| Sam

22.22 | terrible

| Rowe
|

| Daniel

| Sam

22.22 | no bueno

| Starton | Max
|

| Sam

22.22 | dont play sports | $22.22

| Darton
|

| Sam

22.22 | good

| Bull
|

| David
| Emily

| Sam

22.22 | eh

| $22.22
| $22.22

| $22.22
| $22.22

| Smith
|

| Sam

| Daphne |

21.11 | terrible

| Rowe
|

| Daniel

| Daphne |

21.11 | no bueno

| Daphne |

21.11 | dont play sports | $21.11

| Starton | Max

| $21.11
| $21.11

|
| Darton
|
| Bull
|

| David
| Emily

| Daphne |
| Daphne |

21.11 | good

| $21.11

21.11 | eh

| $21.11
| $20.11

| Smith
|

| Sam

| Sara

20.11 | terrible

| Rowe
|

| Daniel

| Sara

20.11 | no bueno

| Starton | Max
|

| Sara

20.11 | dont play sports | $20.11

| Darton
|

| Sara

20.11 | good

| Bull
|

| David
| Emily

| Sara

20.11 | eh

| $20.11

| $20.11
| $20.11

| Smith
|

| Sam

| Sally

22.41 | terrible

| Rowe
|

| Daniel

| Sally

22.41 | no bueno

| Starton | Max
|

| Sally

22.41 | dont play sports | $22.41

| Darton
|

| Sally

22.41 | good

| Bull
|

| David
| Emily

| Sally

22.41 | eh

| $22.41
| $22.41

| $22.41
| $22.41

| Smith
|

| Sam

| Lauren |

51.12 | terrible

| Rowe
|

| Daniel

| Lauren |

51.12 | no bueno

| Lauren |

51.12 | dont play sports | $51.12

| Starton | Max
|

| $51.12
| $51.12

| Darton
|
| Bull
|

| David
| Emily

| Lauren |
| Lauren |

51.12 | good
51.12 | eh

+-----------+-----------+----------+----------+-----------------+----------------------------------+
25 rows in set (0.00 sec)

4. delete from part

mysql> delete from participant


-> where par_id=21;
Query OK, 1 row affected (0.02 sec)

5.
mysql> update student
-> set stu_lname='Stellar'
-> where stu_id='2';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select stu_lname, stu_fname, stu_id


-> from student
-> where stu_id='2';
+-----------+-----------+--------+
| stu_lname | stu_fname | stu_id |

| $51.12
| $51.12

+-----------+-----------+--------+
| Stellar | Daniel

2|

+-----------+-----------+--------+
1 row in set (0.00 sec)

6. mysql> insert into activity


-> (act_name, act_cost, act_start_date, act_end_date,act_notes)
-> values
-> ('archery','399','2013-04-01','2013-04-01','course materials
included'),
-> ('martial arts','599','2013-05-01','2013-08-01','additional course
materials required');
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0

7. mysql> select * from activity;


+--------+--------------+----------+----------------+--------------------+--------------------------------------+
| act_id | act_name
act_notes

| act_cost | act_start_date | act_end_date


|

+--------+--------------+----------+----------------+--------------------+--------------------------------------+
|
6 | Sam
NULL
|
7 | Daphne
NULL

22.22 | 2014-12-12
|
|

21.11 | 2015-12-12
|

| 2015-12-12 00:00:00 |
| 2016-12-12 00:00:00 |

|
8 | Sara
NULL

20.11 | 2016-12-12
|

| 2017-12-12 00:00:00 |

|
9 | Sally
NULL

22.41 | 2017-12-12
|

| 2018-12-12 00:00:00 |

|
10 | Lauren
NULL

51.12 | 2018-12-12
|

|
11 | archery
| 399.00 | 2013-04-01
course materials included
|
|
12 | martial arts | 599.00 | 2013-05-01
additional course materials required |

| 2019-12-12 00:00:00 |
| 2013-04-01 00:00:00 |
| 2013-08-01 00:00:00 |

+--------+--------------+----------+----------------+--------------------+--------------------------------------+
7 rows in set (0.00 sec)

Você também pode gostar