Guest User

Untitled

a guest
Aug 14th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. SELECT
  2. Person.personId,
  3. Person.personCode,
  4. Person.fName,
  5. Person.lName,
  6. PersonT.fName2,
  7. PersonT.lName2,
  8. PersonT.birthDate,
  9. rs_academic_position.acp_name_th,
  10. PersonT.emailAddr AS email,
  11. (
  12. CASE Person.fStatus
  13. WHEN 1 THEN 'ยังปฏิบัติงานอยู่'
  14. WHEN 2 THEN 'ไม่ได้ปฏิบัติงานแล้ว'
  15. ELSE null
  16. END
  17. ) AS PersonStatus,
  18. history_education.history_education,
  19. history_work.history_work
  20. FROM Person
  21. LEFT JOIN PersonT ON PersonT.personId = Person.personId
  22. LEFT JOIN rs_academic ON rs_academic.ac_ps_id = Person.personId
  23. LEFT JOIN rs_academic_position ON rs_academic_position.acp_id = rs_academic.ac_acp_id
  24. LEFT JOIN (
  25. SELECT CONCAT(
  26. '[',
  27. GROUP_CONCAT(JSON_OBJECT(
  28. 'levelName',Level.levelName,
  29. 'levelNameEng',Level.levelNameEng,
  30. 'degreeName',Degree.degreeName,
  31. 'educmajorName',Educmajor.educmajorName,
  32. 'educplaceName',Educplace.educplaceName,
  33. 'countryName',Country.countryName
  34. )),
  35. ']') AS history_education,
  36. Education.personId as personId
  37. FROM Education
  38. JOIN Level
  39. JOIN Degree
  40. JOIN Educmajor
  41. JOIN Educplace
  42. JOIN Country
  43. WHERE Education.levelId = Level.levelId
  44. AND Education.degreeId = Degree.degreeId
  45. AND Education.educmajorId = Educmajor.educmajorId
  46. AND Education.educplaceId = Educplace.educplaceId
  47. AND Education.countryId = Country.countryId
  48. GROUP BY Education.personId
  49. ) AS history_education ON history_education.personId = Person.personId
  50. LEFT JOIN (
  51. SELECT CONCAT(
  52. '[',
  53. GROUP_CONCAT(JSON_OBJECT(
  54. 'start_date',moresearcher.rs_experience.ex_start_date,
  55. 'end_date',moresearcher.rs_experience.ex_end_date,
  56. 'position',moresearcher.rs_experience.ex_position,
  57. 'workplace',moresearcher.rs_experience.ex_workplace
  58. )),
  59. ']') AS history_work,
  60. moresearcher.rs_user.us_ps_id AS personId
  61. FROM moresearcher.rs_user
  62. JOIN moresearcher.rs_experience
  63. WHERE moresearcher.rs_experience.ex_us_id = moresearcher.rs_user.us_id
  64. GROUP BY moresearcher.rs_user.us_ps_id
  65. ) AS history_work ON history_work.personId = Person.personId
Add Comment
Please, Sign In to add comment