1

enter image description here Here is my code

SELECT   
              register cr.id,
              register_cr.first_name,
              register_cr.father_name,
              register_cr.surname,
              register_cr.address,
              cr_record.charge,
              cr_record.date,
              cr_record.charge_type,
              cr_record.fir_no
FROM 
             register_cr as register_cr
INNER JOIN 
             cr_record as cr_record ON register_cr.id = cr_record.cri_reco_id
5
  • Do you have the right to store this data? Oct 31 '18 at 19:55
  • Can you provide an example of the output you are looking for?
    – Joe W
    Oct 31 '18 at 20:10
  • yes i have right for this
    – Mangesh
    Oct 31 '18 at 20:17
  • Please post that as text rather then an image as there are plenty of work networks where imgur is blocked which makes people unable to help.
    – Joe W
    Oct 31 '18 at 20:38
  • 1
    Formatting is better done at the application level.
    – Rick James
    Nov 1 '18 at 5:23
3

The GROUP_CONCAT allows this form of transformation:

SELECT   
              register_cr.id,
              register_cr.first_name,
              register_cr.father_name,
              register_cr.surname,
              register_cr.address,
              GROUP_CONCAT(DISTINCT cr_record.charge SEPARATOR "\n"),
              GROUP_CONCAT(DISTINCT cr_record.date SEPARATOR "\n"),
              GROUP_CONCAT(DISTINCT cr_record.charge_type SEPARATOR "\n"),
              GROUP_CONCAT(DISTINCT cr_record.fir_no SEPARATOR "\n")
FROM 
             register_cr as register_cr
INNER JOIN 
             cr_record as cr_record ON register_cr.id = cr_record.cri_reco_id
GROUP BY register_cr.id
1
  • Thank you for the answer. It was helpful only that the separator was not showing.
    – Mangesh
    Nov 1 '18 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.