mysql [as for monitoring] Flashcards

1
Q

Select specific columns from table

A

select , from ;

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

Select all names beginning with “Olya” from table “friends”

A

select * from friends where name = ‘Olya%’;

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

Select all names ending with “Matveyev” from table “friends”

A

select * from friends where name = ‘%Matveyev”;

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

Select all friends that are called “Ratmir” and are interested in “flying”

A

select * from friends where name = ‘Ratmir’ AND interest = ‘flying’;

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

Select by id all friends with their interest and days we know one another

A

select ID, CONCAT(name, ‘ interested in ‘, interest) AS name, daysknow from friends;

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

Display the total number of employees in every department of a company

A
mysql> SELECT DEPT, COUNT(*) FROM employee GROUP BY DEPT;
\+------------+----------+
| dept       | count(*) |
\+------------+----------+
| Accounting |        1 |
| Marketing  |        1 |
| Sales      |        1 |
| Technology |        3 |
\+------------+----------+
4 rows in set (0.00 sec)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly