Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.01 KB | None | 0 0
  1. ###########################################
  2. # OP 1
  3. ###########################################
  4. # Broken United States
  5. # Select broken countries.
  6. SELECT
  7. field_ro_country_value
  8. FROM
  9. d8_node__field_ro_country
  10. WHERE
  11. field_ro_country_value = 'United States'
  12. ;
  13.  
  14. # Location adjustments, so data is consistent.
  15. # Done (3 records updated)
  16. UPDATE
  17. d8_node__field_ro_country
  18. SET
  19. field_ro_country_value = 'United States of America'
  20. WHERE
  21. field_ro_country_value = 'United States'
  22. ;
  23. ###########################################
  24. # END OF OP 1
  25. ###########################################
  26.  
  27. ###########################################
  28. # OP 2
  29. ###########################################
  30. # Select Single entity
  31. # https://takeielts.britishcouncil.org/recognising-organisation/wwwmhe-krgorg
  32. # Iraq with website url instead of univercity name in title - country should be Iraq, city should be Erbil
  33. SELECT
  34. d8_node_field_data.nid as id,
  35. d8_node_field_data.title,
  36. field_ro_country_value as country
  37. FROM
  38. d8_node_field_data
  39. INNER JOIN d8_node__field_ro_country
  40. ON d8_node_field_data.nid = d8_node__field_ro_country.entity_id
  41. WHERE d8_node_field_data.nid = 4388
  42. ;
  43.  
  44. # Location and title adjustments, so data is consistent.
  45. # Done (1 record updated)
  46. UPDATE
  47. d8_node_field_data
  48. SET
  49. title = 'Ministry of Higher Education and Scientific Research'
  50. WHERE
  51. d8_node_field_data.nid = 4388
  52. ;
  53.  
  54. UPDATE
  55. d8_node__field_ro_country
  56. SET
  57. field_ro_country_value = 'Iraq'
  58. WHERE
  59. d8_node__field_ro_country.entity_id = 4388
  60. ;
  61.  
  62. # Insert Ebril City into cities table for 4388
  63. INSERT INTO
  64. d8_node__field_ro_city
  65. VALUES
  66. ('ro', 0, 4388, 4684, 'en', 0, 'Erbil')
  67. ;
  68.  
  69. ###########################################
  70. # END OF OP 2
  71. ###########################################
  72.  
  73. ###########################################
  74. # OP 3
  75. ###########################################
  76. # Select Single entity
  77. # https://takeielts.britishcouncil.org/recognising-organisation/portalufesbr
  78. # Iraq with website url instead of univercity name in title - country should be Brazil, city should be Vitoria
  79. SELECT
  80. d8_node_field_data.nid as id,
  81. d8_node_field_data.title,
  82. field_ro_country_value as country,
  83. d8_node__field_ro_city.field_ro_city_value as city,
  84. d8_node__field_ro_city.revision_id
  85. FROM
  86. d8_node_field_data
  87. INNER JOIN d8_node__field_ro_country
  88. ON d8_node_field_data.nid = d8_node__field_ro_country.entity_id
  89. INNER JOIN d8_node__field_ro_city
  90. ON d8_node__field_ro_city.entity_id = d8_node_field_data.nid
  91. WHERE d8_node_field_data.nid = 7319
  92. ;
  93.  
  94. # Location and title adjustments, so data is consistent.
  95. # Done (1 record updated)
  96. UPDATE
  97. d8_node_field_data
  98. SET
  99. title = 'Universidade Federal do Espirito Santo'
  100. WHERE
  101. d8_node_field_data.nid = 7319
  102. ;
  103.  
  104. UPDATE
  105. d8_node__field_ro_country
  106. SET
  107. field_ro_country_value = 'Brasil'
  108. WHERE
  109. d8_node__field_ro_country.entity_id = 7319
  110. ;
  111.  
  112. # Insert Vitoria city into cities table for 7319
  113. INSERT INTO
  114. d8_node__field_ro_city
  115. VALUES
  116. ('ro', 0, 7319, 7722, 'en', 0, 'Vitoria')
  117. ;
  118.  
  119. ###########################################
  120. # END OF OP 3
  121. ###########################################
  122.  
  123. ###########################################
  124. # OP 4
  125. ###########################################
  126. # Select Single entity
  127. # https://takeielts.britishcouncil.org/recognising-organisation/institute-philosophy-and-sociology-pan
  128. # State is set to Warsaw. To change: remove state, add Warsaw as city and Poland as country
  129. SELECT
  130. d8_node_field_data.nid as id,
  131. d8_node_field_data.title,
  132. field_ro_country_value as country,
  133. d8_node__field_ro_city.field_ro_city_value as city,
  134. d8_node__field_state.field_state_value as state,
  135. d8_node_field_data.vid as revision_id
  136. FROM
  137. d8_node_field_data
  138. LEFT JOIN d8_node__field_ro_country
  139. ON d8_node_field_data.nid = d8_node__field_ro_country.entity_id
  140. LEFT JOIN d8_node__field_ro_city
  141. ON d8_node__field_ro_city.entity_id = d8_node_field_data.nid
  142. LEFT JOIN d8_node__field_state
  143. ON d8_node_field_data.nid = d8_node__field_state.entity_id
  144. WHERE d8_node_field_data.nid = 10564
  145. ;
  146.  
  147. # Location and title adjustments, so data is consistent.
  148. # Done (1 record removed, 2 added)
  149. DELETE FROM
  150. d8_node__field_state
  151. WHERE
  152. entity_id = 10564
  153. AND
  154. revision_id = 10973
  155. ;
  156.  
  157. # Insert Warsaw city into cities table for 10564
  158. INSERT INTO
  159. d8_node__field_ro_city
  160. VALUES
  161. ('ro', 0, 10564, 10973, 'en', 0, 'Warsaw')
  162. ;
  163.  
  164. # Insert Poland country into countries table for 10564
  165. INSERT INTO
  166. d8_node__field_ro_country
  167. VALUES
  168. ('ro', 0, 10564, 10973, 'en', 0, 'Poland')
  169. ;
  170.  
  171. ###########################################
  172. # END OF OP 4
  173. ###########################################
  174.  
  175. ###########################################
  176. # OP 5
  177. ###########################################
  178. # Select Single entity
  179. # https://takeielts.britishcouncil.org/recognising-organisation/university-wisconsin-flexible-option
  180. # Country is set to Wisconsin. To change: change country, add state, add city of Madison
  181. SELECT
  182. d8_node_field_data.nid as id,
  183. d8_node_field_data.title,
  184. field_ro_country_value as country,
  185. d8_node__field_ro_city.field_ro_city_value as city,
  186. d8_node__field_state.field_state_value as state,
  187. d8_node_field_data.vid as revision_id
  188. FROM
  189. d8_node_field_data
  190. LEFT JOIN d8_node__field_ro_country
  191. ON d8_node_field_data.nid = d8_node__field_ro_country.entity_id
  192. LEFT JOIN d8_node__field_ro_city
  193. ON d8_node__field_ro_city.entity_id = d8_node_field_data.nid
  194. LEFT JOIN d8_node__field_state
  195. ON d8_node_field_data.nid = d8_node__field_state.entity_id
  196. WHERE d8_node_field_data.nid = 10222
  197. ;
  198.  
  199. # Location and title adjustments, so data is consistent.
  200. # Done (2 records updated, 1 added)
  201.  
  202. # Insert Madison city into cities table
  203. INSERT INTO
  204. d8_node__field_ro_city
  205. VALUES
  206. ('ro', 0, 10222, 18424, 'en', 0, 'Madison')
  207. ;
  208.  
  209. # Insert Wisconsin state into states table
  210. UPDATE
  211. d8_node__field_state
  212. SET
  213. field_state_value = 'Wisconsin'
  214. WHERE
  215. entity_id = 10222 and revision_id = 18424
  216. ;
  217.  
  218.  
  219. # Update Wisconsin to United States of America for 10564
  220. UPDATE
  221. d8_node__field_ro_country
  222. SET
  223. field_ro_country_value = 'United States of America'
  224. WHERE
  225. entity_id = 10222 and revision_id = 18424
  226. ;
  227.  
  228. ###########################################
  229. # END OF OP 5
  230. ###########################################
  231.  
  232. ###########################################
  233. # OP 6
  234. ###########################################
  235. # Select Single entity
  236. # https://takeielts.britishcouncil.org/recognising-organisation/oak-valley-college
  237. # Country is set to California, state to Oak Glen. To change: update country, update state, add city of Oak Glen
  238. SELECT
  239. d8_node_field_data.nid as id,
  240. d8_node_field_data.title,
  241. field_ro_country_value as country,
  242. d8_node__field_ro_city.field_ro_city_value as city,
  243. d8_node__field_state.field_state_value as state,
  244. d8_node_field_data.vid as revision_id
  245. FROM
  246. d8_node_field_data
  247. LEFT JOIN d8_node__field_ro_country
  248. ON d8_node_field_data.nid = d8_node__field_ro_country.entity_id
  249. LEFT JOIN d8_node__field_ro_city
  250. ON d8_node__field_ro_city.entity_id = d8_node_field_data.nid
  251. LEFT JOIN d8_node__field_state
  252. ON d8_node_field_data.nid = d8_node__field_state.entity_id
  253. WHERE d8_node_field_data.nid = 10867
  254. ;
  255.  
  256. # Location and title adjustments, so data is consistent.
  257. # Done (2 records updated, 1 added)
  258.  
  259. # Insert Madison city into cities table
  260. INSERT INTO
  261. d8_node__field_ro_city
  262. VALUES
  263. ('ro', 0, 10867, 11276, 'en', 0, 'Oak Glen')
  264. ;
  265.  
  266. # Insert Oak Glen to California state into states table
  267. UPDATE
  268. d8_node__field_state
  269. SET
  270. field_state_value = 'California'
  271. WHERE
  272. entity_id = 10867 and revision_id = 11276
  273. ;
  274.  
  275.  
  276. # Update California to United States of America for 10564
  277. UPDATE
  278. d8_node__field_ro_country
  279. SET
  280. field_ro_country_value = 'United States of America'
  281. WHERE
  282. entity_id = 10867 and revision_id = 11276
  283. ;
  284.  
  285. ###########################################
  286. # END OF OP 6
  287. ###########################################
  288.  
  289. # Location select.
  290. (
  291. SELECT DISTINCT
  292. field_ro_country_value as location,
  293. NULL as parent_country,
  294. NULL as parent_state
  295. FROM
  296. d8_node__field_ro_country
  297. WHERE
  298. bundle = 'ro'
  299. )
  300.  
  301. UNION
  302.  
  303. (
  304. SELECT DISTINCT
  305. d8_node__field_state.field_state_value as location,
  306. d8_node__field_ro_country.field_ro_country_value as parent_country,
  307. NULL as parent_state
  308. FROM
  309. d8_node__field_state LEFT JOIN d8_node__field_ro_country
  310. ON
  311. d8_node__field_state.entity_id = d8_node__field_ro_country.entity_id
  312. WHERE
  313. d8_node__field_state.bundle = 'ro'
  314. )
  315.  
  316. UNION
  317.  
  318. (
  319. SELECT DISTINCT
  320. d8_node__field_ro_city.field_ro_city_value as location,
  321. d8_node__field_ro_country.field_ro_country_value as parent_country,
  322. d8_node__field_state.field_state_value as parent_state
  323.  
  324. FROM
  325. d8_node__field_ro_city
  326. LEFT JOIN d8_node__field_ro_country ON d8_node__field_ro_city.entity_id = d8_node__field_ro_country.entity_id
  327. LEFT JOIN d8_node__field_state ON d8_node__field_ro_city.entity_id = d8_node__field_state.entity_id
  328.  
  329. WHERE
  330. d8_node__field_ro_city.bundle = 'ro'
  331. )
  332. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement