SHARE
TWEET

My Longest Query Ever

abujen001 Sep 13th, 2017 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT fname AS 'Complainant First Name', mname AS 'Complainant Middle Name', surname AS 'Complainant Surname',
  2.  sex AS 'Complainant Sex', person_address AS 'Complainant Address', citizenship AS 'Complainant Citizenship',
  3.  birthdate AS 'Complainant Birthday', contactnum AS 'Complainant Contact Number', email AS 'Complainant Email Address',
  4.  
  5.  date_received, case_details, lagdo_ccn, nbi_ccn, nbi_acmo, nature_of_case,
  6.  
  7. (SELECT fname FROM persons_tbl
  8. INNER JOIN case_victim_tbl ON persons_tbl.person_id = case_victim_tbl.person_id) AS 'Victim First Name',
  9. (SELECT mname FROM persons_tbl
  10. INNER JOIN case_victim_tbl ON persons_tbl.person_id = case_victim_tbl.person_id) AS 'Victim Middle Name',
  11. (SELECT surname FROM persons_tbl
  12. INNER JOIN case_victim_tbl ON persons_tbl.person_id = case_victim_tbl.person_id) AS 'Victim Surname',
  13. (SELECT sex FROM persons_tbl
  14. INNER JOIN case_victim_tbl ON persons_tbl.person_id = case_victim_tbl.person_id) AS 'Victim Sex',
  15. (SELECT person_address FROM persons_tbl
  16. INNER JOIN case_victim_tbl ON persons_tbl.person_id = case_victim_tbl.person_id) AS 'Victim Address',
  17. (SELECT citizenship FROM persons_tbl
  18. INNER JOIN case_victim_tbl ON persons_tbl.person_id = case_victim_tbl.person_id) AS 'Victim Citizenship',
  19. (SELECT birthdate FROM persons_tbl
  20. INNER JOIN case_victim_tbl ON persons_tbl.person_id = case_victim_tbl.person_id) AS 'Victim Birthday',
  21. (SELECT contactnum FROM persons_tbl
  22. INNER JOIN case_victim_tbl ON persons_tbl.person_id = case_victim_tbl.person_id) AS 'Victim Contact Number',
  23. (SELECT email FROM persons_tbl
  24. INNER JOIN case_victim_tbl ON persons_tbl.person_id = case_victim_tbl.person_id) AS 'Victim Email Address',
  25.  
  26. (SELECT fname FROM persons_tbl
  27. INNER JOIN case_subject_tbl ON persons_tbl.person_id = case_subject_tbl.person_id) AS 'Subject First Name',
  28. (SELECT mname FROM persons_tbl
  29. INNER JOIN case_subject_tbl ON persons_tbl.person_id = case_subject_tbl.person_id) AS 'Subject Middle Name',
  30. (SELECT surname FROM persons_tbl
  31. INNER JOIN case_subject_tbl ON persons_tbl.person_id = case_subject_tbl.person_id) AS 'Subject Surname',
  32. (SELECT sex FROM persons_tbl
  33. INNER JOIN case_subject_tbl ON persons_tbl.person_id = case_subject_tbl.person_id) AS 'Subject Sex',
  34. (SELECT person_address FROM persons_tbl
  35. INNER JOIN case_subject_tbl ON persons_tbl.person_id = case_subject_tbl.person_id) AS 'Subject Address',
  36. (SELECT citizenship FROM persons_tbl
  37. INNER JOIN case_subject_tbl ON persons_tbl.person_id = case_subject_tbl.person_id) AS 'Subject Citizenship',
  38. (SELECT birthdate FROM persons_tbl
  39. INNER JOIN case_subject_tbl ON persons_tbl.person_id = case_subject_tbl.person_id) AS 'Subject Birthday',
  40. (SELECT contactnum FROM persons_tbl
  41. INNER JOIN case_subject_tbl ON persons_tbl.person_id = case_subject_tbl.person_id) AS 'Subject Contact Number',
  42. (SELECT fname FROM persons_tbl
  43. INNER JOIN case_subject_tbl ON persons_tbl.person_id = case_subject_tbl.person_id) AS 'Subject Email Address'
  44.  
  45. FROM persons_tbl
  46. INNER JOIN case_complainant_tbl ON persons_tbl.person_id = case_complainant_tbl.person_id
  47. INNER JOIN case_tbl ON case_complainant_tbl.case_id = case_tbl.case_id
  48. INNER JOIN citizenship_tbl ON persons_tbl.citizenship_id = citizenship_tbl.citizenship_id
  49. INNER JOIN nature_case_tbl ON case_tbl.nature_case_id = nature_case_tbl.nature_case_id
  50. WHERE lagdo_ccn = 'C-17-09-0001'
RAW Paste Data
Pastebin PRO Autumn Special!
Get 40% OFF on Pastebin PRO accounts!
Top