Connecting Tech Pros Worldwide Forums | Help | Site Map

make one table from merging two

Familiar Sight
 
Join Date: Oct 2008
Posts: 128
#1: Jul 14 '09
i hav two tables
table1
fiels;sid,sname,saddress
table2
fields;sid,smarks,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's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Jul 15 '09

re: make one table from merging two


yes, use join...

what do you have so far?

happy coding !!!

-- CK
Newbie
 
Join Date: Jul 2009
Posts: 9
#3: Jul 15 '09

re: make one table from merging two


SELECT * FROM
Table1 INNER JOIN Table2 ON Table1.SID=Table2.SID

OR

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

HAPPY QUERY...
- Pankaj Tambe
Newbie
 
Join Date: Jul 2009
Posts: 5
#4: Jul 16 '09

re: make one table from merging two


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.smarks
sresult=t2.sresult
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,
Reply