mysql [as for monitoring] Flashcards
1
Q
Select specific columns from table
A
select , from ;
2
Q
Select all names beginning with “Olya” from table “friends”
A
select * from friends where name = ‘Olya%’;
3
Q
Select all names ending with “Matveyev” from table “friends”
A
select * from friends where name = ‘%Matveyev”;
4
Q
Select all friends that are called “Ratmir” and are interested in “flying”
A
select * from friends where name = ‘Ratmir’ AND interest = ‘flying’;
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;
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)