Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 3.52 KB | None | 0 0
  1. CREATE TABLE `applicants` (
  2.     `first_name`    TEXT,
  3.     `last_name` TEXT,
  4.     `phone_number`  TEXT,
  5.     `email` TEXT,
  6.     `application_code`  INTEGER
  7. );
  8.  
  9.  
  10. CREATE TABLE `mentors` (
  11.     `first_name`    TEXT,
  12.     `last_name` TEXT,
  13.     `nick_name` TEXT,
  14.     `phone_number`  TEXT,
  15.     `email` TEXT,
  16.     `city`  TEXT,
  17.     `favourite_number`  INTEGER
  18. );
  19.  
  20.  
  21. 1. Write a query that returns the 2 name columns of the mentors table.
columns: first_name, last_name
  22.  
  23. SELECT `first_name` AS `Imię`, `last_name` AS `Nazwisko` FROM `mentors`;
  24.  
  25.  
  26. 2. Write a query that returns the nick_name-s of all mentors working at Miskolc.
column: nick_name
  27.  
  28. SELECT * FROM `mentors` WHERE `city` LIKE 'Miskolc' ;
  29.  
  30.  
  31. 3. We had interview with an applicant, some Carol. We don't remember her name, but she left her hat at the school. We want to call her to give her back her hat. To look professional, we also need her full name when she answers the phone (for her full_name, you want to include a concatenation into your query, to get her full_name, like: "Carol Something" instead of having her name in 2 different columns in the result. This columns should be called: full_name).
columns: full_name, phone_number
  32.  
  33. SELECT `first_name`|| " " ||`last_name` AS `full_name`, `phone_number`
  34. FROM `applicants`
  35. WHERE `phone_number` LIKE '003620/496-7064';
  36.  
  37.  
  38. 4. We called Carol, and she said it's not her hat. It belongs to another girl, who went to the famous Adipiscingenimmi University.
You should write a query to get the same informations like with Carol, but for this other girl.
The only thing we know about her is her school e-mail address ending: '@adipiscingenimmi.edu'.
columns: full_name, phone_number
  39.  
  40. SELECT `first_name`|| " " ||`last_name` AS `full_name`, `phone_number`
  41. FROM `applicants`
  42. WHERE `email` like '%@adipiscingenimmi.edu';
  43.  
  44.  
  45. 5. After we returned the hat, a new applicant appeared at the school, and he wants to get into the application process.
  46. His name is Markus Schaffarzyk, has a number: 003620/725-2666 and e-mail address: djnovus@groovecoverage.com
  47. Our generator gave him the following application code: 54823
  48.  
  49. After INSERTing the data, write a SELECT query, that returns with all the columns of this applicant! (use the unique application code for your condition!)
  50.  
  51. INSERT INTO `applicants` (`first_name`, `last_name`, `phone_number`, `email`, `application_code`)
  52. VALUES ('Markus', 'Schaffarzyk', '003620/725-2666', 'djnovus@groovecoverage.com', 54823);
  53.  
  54. Or
  55.  
  56. INSERT INTO `applicants`
  57. VALUES ('Markus', 'Schaffarzyk', '003620/725-2666', 'djnovus@groovecoverage.com', 54823);
  58.  
  59. SELECT * FROM `applicants`
  60. WHERE `application_code` = 54823;
  61.  
  62.  
  63.  
  64.  
  65. 6. Jemima Foreman, an applicant called us, that her phone number changed to: 003670/223-7459Write an UPDATE query, that changes this data in the database for this applicant.
Also, write a SELECT query, that checks the phone_number column of this applicant.
Use both of her name parts in the conditions!
  66.  
  67. UPDATE `applicants`
  68. SET `phone_number` = '003670/223-7459'
  69. WHERE `first_name` = 'Jemima' AND `last_name` = 'Foreman';
  70.  
  71. SELECT `phone_number`
  72. FROM `applicants`
  73. WHERE `first_name` = 'Jemima' AND `last_name` = 'Foreman';
  74.  
  75.  
  76.  
  77. 7. Arsenio, an applicant called us, that he and his friend applied to Codecool.
They both want to cancel the process, because they got an investor for the site they run: mauriseu.net
  78. Write DELETE query to remove all the applicants, who applied with emails for this domain (e-mail address has this domain after the @ sign).
  79.  
  80. DELETE FROM `applicants`
  81. WHERE `email` like '%mauriseu.net';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement