Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. getting common data

getting common data

Scheduled Pinned Locked Moved Database
help
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arun kumar Gautam
    wrote on last edited by
    #1

    i have 3 tables named as patient, medicine, attachment patient table has columns name as patient_id patient_name medicine tables has columns med_id medicine_name patient_id and attachment has columns attachment_id attachment patient_id now i want data as patient_name medicine_name attachment where attachment_table has 2 or more columns who have same patient_id same as happn with attachment table but the main problem is i want to get all the data into a single row even if attachment has particular patient or no same as if medicine table has particular patient_id or no so can any one help me in it

    L P 2 Replies Last reply
    0
    • A Arun kumar Gautam

      i have 3 tables named as patient, medicine, attachment patient table has columns name as patient_id patient_name medicine tables has columns med_id medicine_name patient_id and attachment has columns attachment_id attachment patient_id now i want data as patient_name medicine_name attachment where attachment_table has 2 or more columns who have same patient_id same as happn with attachment table but the main problem is i want to get all the data into a single row even if attachment has particular patient or no same as if medicine table has particular patient_id or no so can any one help me in it

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Patient
      Patient_id
      Patient_name

      Medicine
      med_id
      medicine_name
      patient_id

      attachment
      attachment_id
      attachment
      patient_id

      Let's use "Coffee" as a sample medication; if both you and me were to be medicated with coffee, the medicine would need to be inserted into the "medicine" table twice. That's a modelling error.

      Arun kumar Gautam wrote:

      now i want data as
      patient_name medicine_name attachment

      I'd suggest you first fix your database-model. You can try Normalization[^] to correct it, or hope that someone else comes up with a different design. FWIW, it'd be best to register which patient takes which medication in a separate table. Once you have that, it's easy to join the tables and display them in a single row. Further, I'd also recommend to change the naming-pattern of the fields. As is, the name of the table is often repeated in the fieldname, wich is redundant.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

      1 Reply Last reply
      0
      • A Arun kumar Gautam

        i have 3 tables named as patient, medicine, attachment patient table has columns name as patient_id patient_name medicine tables has columns med_id medicine_name patient_id and attachment has columns attachment_id attachment patient_id now i want data as patient_name medicine_name attachment where attachment_table has 2 or more columns who have same patient_id same as happn with attachment table but the main problem is i want to get all the data into a single row even if attachment has particular patient or no same as if medicine table has particular patient_id or no so can any one help me in it

        P Offline
        P Offline
        prakash chakrala
        wrote on last edited by
        #3

        Hi Arun kumar Could you provide sample data for understanding purpose and from that how you want the data could you give sample output Regards, Prakash.ch

        Prakash.ch

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups