Click here to Skip to main content
15,921,694 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 2 tables each 1 have diff colum diff data each table have primary key
i want 2 insert the data to 3rd table. 3rd tble have same colum (tb1&tb2)

wen i inserting data into tb1 tb2 .the insert value should update table 3 i try this code
i dont know wat im wrong
SQL
INSERT INTO AccType SELECT Login.*,col1,col2,col3 FROM Login,Verify WHERE Login.Username="+Label2.Text+" AND Verify.Username="+Label2.Text+""
">
username is primary

im using sql2008
Acctype table contains username,pass,emailid,address,mobile: all columns varchar(50)
login tbl hav username,pass,address all columns varchar(50)
verify tble hav username,emailid,mobile all columns varchar(50)
Posted
Updated 7-Apr-13 20:20pm
v2
Comments
Maciej Los 8-Apr-13 2:12am    
Post the structure of database and example data.
PRAKASH9 8-Apr-13 3:45am    
pls define your proper columns of table

1 solution

Hi msashwin03,

Try using the column names instead of simply using the Login.*. Also specify the Column names in the AccType.

Eg:

INSERT INTO AccType (Col1, Col2, Col3,..)
SELECT LOGIN.Col1, LOGIN.Col2, ... etc FROM...

Thank you,
Vamsi
 
Share this answer
 
Comments
msashwin03 8-Apr-13 2:38am    
im using 3 tables plz review my post

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900