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. merging two database

merging two database

Scheduled Pinned Locked Moved Database
database
5 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.
  • C Offline
    C Offline
    chandru70
    wrote on last edited by
    #1

    i have 3 tables 1 master 2 advance 3 loan here some employe taken only advance,some only loan ,some both and some not availed. i want to list like this those are availed. emp_code emp_name adv_amt, loan emp_code is id for all three files regards chandru

    V K 2 Replies Last reply
    0
    • C chandru70

      i have 3 tables 1 master 2 advance 3 loan here some employe taken only advance,some only loan ,some both and some not availed. i want to list like this those are availed. emp_code emp_name adv_amt, loan emp_code is id for all three files regards chandru

      V Offline
      V Offline
      vivek g
      wrote on last edited by
      #2

      SELECT MASTER.EMP_CODE,MASTER.EMP_NAME,ADVANCE.ADV_AMT, LOAN.LOAN FROM MASTER ,ADVANCE,LOAN WHERE MASTER.EMP_CODE=ADVANCE.EMP_CODE AND MASTER.EMP_CODE=LOAN.EMP_CODE AND LOAN.AVAILED='Y'

      vivek

      C 1 Reply Last reply
      0
      • C chandru70

        i have 3 tables 1 master 2 advance 3 loan here some employe taken only advance,some only loan ,some both and some not availed. i want to list like this those are availed. emp_code emp_name adv_amt, loan emp_code is id for all three files regards chandru

        K Offline
        K Offline
        Krish KP
        wrote on last edited by
        #3

        SELECT emp_code, emp_name, sum(adv_amt) as adv_amt, sum(load) AS loan FROM ( SELECT emp_code, emp_name, adv_amt, 0 AS loan FROM master m INNER JOIN advance a ON m.emp_code = a.emp_code UNION ALL SELECT emp_code, emp_name, 0 AS adv_amt, loan FROM master m INNER JOIN loan l ON m.emp_code = l.emp_code )a GROUP BY emp_code, emp_name

        Regards KP

        C 1 Reply Last reply
        0
        • K Krish KP

          SELECT emp_code, emp_name, sum(adv_amt) as adv_amt, sum(load) AS loan FROM ( SELECT emp_code, emp_name, adv_amt, 0 AS loan FROM master m INNER JOIN advance a ON m.emp_code = a.emp_code UNION ALL SELECT emp_code, emp_name, 0 AS adv_amt, loan FROM master m INNER JOIN loan l ON m.emp_code = l.emp_code )a GROUP BY emp_code, emp_name

          Regards KP

          C Offline
          C Offline
          chandru70
          wrote on last edited by
          #4

          thank you chandru

          1 Reply Last reply
          0
          • V vivek g

            SELECT MASTER.EMP_CODE,MASTER.EMP_NAME,ADVANCE.ADV_AMT, LOAN.LOAN FROM MASTER ,ADVANCE,LOAN WHERE MASTER.EMP_CODE=ADVANCE.EMP_CODE AND MASTER.EMP_CODE=LOAN.EMP_CODE AND LOAN.AVAILED='Y'

            vivek

            C Offline
            C Offline
            chandru70
            wrote on last edited by
            #5

            by excuting this query only those records who are availed both loan, advance will be displayed. thank you chandru

            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