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. Records on the basis of two different tables.

Records on the basis of two different tables.

Scheduled Pinned Locked Moved Database
databasesql-serversysadmin
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.
  • R Offline
    R Offline
    Rohit Kesharwani
    wrote on last edited by
    #1

    Suppose I have two tables (Emp and EmpCopy) in sql server database with following data: Case 1: Data in Emp and EmpCopy table present like below: Table: Emp Id Name ---------------------- 1 Emp_Name 2 Emp_Age 3 Emp_City Table: EmpCopy Id Name -------------------- 1 Emp_Name 2 Emp_Age Case 2: Data in Emp and EmpCopy table present like below: Table: Emp Id Name -------------------- 1 Emp_Name 2 Emp_Age Table: EmpCopy Id Name --------------------- 1 Emp_Name 2 Emp_Age 3 Emp_City Now according to cases given above I want retrieve records from both the tables, just like given below Case 1: Id Emp_Column EmpCopy_Column 1 Emp_Name Emp_Name 2 Emp_Age Emp_Age 3 Emp_City NULL Case 2: Id Emp_Column EmpCopy_Column 1 Emp_Name Emp_Name 2 Emp_Age Emp_Age 3 NULL Emp_City Please reply ASAP. Thanks in advance.

    L 1 Reply Last reply
    0
    • R Rohit Kesharwani

      Suppose I have two tables (Emp and EmpCopy) in sql server database with following data: Case 1: Data in Emp and EmpCopy table present like below: Table: Emp Id Name ---------------------- 1 Emp_Name 2 Emp_Age 3 Emp_City Table: EmpCopy Id Name -------------------- 1 Emp_Name 2 Emp_Age Case 2: Data in Emp and EmpCopy table present like below: Table: Emp Id Name -------------------- 1 Emp_Name 2 Emp_Age Table: EmpCopy Id Name --------------------- 1 Emp_Name 2 Emp_Age 3 Emp_City Now according to cases given above I want retrieve records from both the tables, just like given below Case 1: Id Emp_Column EmpCopy_Column 1 Emp_Name Emp_Name 2 Emp_Age Emp_Age 3 Emp_City NULL Case 2: Id Emp_Column EmpCopy_Column 1 Emp_Name Emp_Name 2 Emp_Age Emp_Age 3 NULL Emp_City Please reply ASAP. Thanks in advance.

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

      Suppose you had a script that created those tables, and inserted some data in it; wouldn't that cost about just as much time as writing all those fields like that? The advantage of a script would be that it's clearly to read, easy to see what is going on, easily validated using copy/paste, and you'd probably get more (usefull) answers - simply because more people tend to paste a piece of Sql and try it, than to read a long story.

      Rohit Kesharwani wrote:

      Please reply ASAP.

      If your boss planned in too little time to research, than that's HIS problem. Not mine, not yours. To prove that point, I'll be fetching some coffee. I suggest you post your code in PRE tags, including one or two queries that you already tried. They needn't be good, we're not going to whine about it; it's just a good idea to have "proof" you tried something.

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

      S 1 Reply Last reply
      0
      • L Lost User

        Suppose you had a script that created those tables, and inserted some data in it; wouldn't that cost about just as much time as writing all those fields like that? The advantage of a script would be that it's clearly to read, easy to see what is going on, easily validated using copy/paste, and you'd probably get more (usefull) answers - simply because more people tend to paste a piece of Sql and try it, than to read a long story.

        Rohit Kesharwani wrote:

        Please reply ASAP.

        If your boss planned in too little time to research, than that's HIS problem. Not mine, not yours. To prove that point, I'll be fetching some coffee. I suggest you post your code in PRE tags, including one or two queries that you already tried. They needn't be good, we're not going to whine about it; it's just a good idea to have "proof" you tried something.

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

        S Offline
        S Offline
        Simon_Whale
        wrote on last edited by
        #3

        Eddy Vluggen wrote:

        To prove that point, I'll be fetching some coffee. I suggest you post your code in PRE tags, including one or two queries that you already tried. They needn't be good, we're not going to whine about it; it's just a good idea to have "proof" you tried something.

        +5 purely for that!

        Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

        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