make one table from merging two

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kkshansid
    New Member
    • Oct 2008
    • 232

    make one table from merging two

    i hav two tables
    table1
    fiels;sid,sname ,saddress
    table2
    fields;sid,smar ks,sresult
    where i can use sid as join condition
    i want to make only one table from these two
    kindly give steps for doing it
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    yes, use join...

    what do you have so far?

    happy coding !!!

    -- CK

    Comment

    • pankajvtcse
      New Member
      • Jul 2009
      • 10

      #3
      SELECT * FROM
      Table1 INNER JOIN Table2 ON Table1.SID=Tabl e2.SID

      OR

      SELECT table1.*,Table2 .* FROM
      Table1 INNER JOIN Table2 ON Table1.SID=Tabl e2.SID

      HAPPY QUERY...
      - Pankaj Tambe

      Comment

      • BhumikaNT
        New Member
        • Jul 2009
        • 5

        #4
        Option 1

        If you want to merge these 2 tables,

        Steps:

        1. Alter table table1 (means, change designing of Table1) and add columns of table2 (i.e. smarks & sresult).

        2. Write update query using join.

        Update Table1
        set smarks=t2.smark s
        sresult=t2.sres ult
        from table1 t1 inner join table2 t2 on
        t1.sid=t2.sid

        3. "drop table table2" Query to delete table2 as it is no more in use for u.

        Another Option

        If u dont want to above then u can create one view which will have merged output. And u can use that view as table anywhere. But u cant update view from outside.

        So, as per your requirement, use the best option.

        Regds,

        Comment

        Working...