In a table test 3 columns contains i need to insert for only 2 columns using the below query method am unable to insert how can i insert for particular column
Table contains 3 columns:
These query not working:- insert test(name1,fname,'XYZ') select name1,fname from test
These query working:- insert test(name1,fname,lname) select name1,fname,lname from test
|
| Author: VinothKumar 04 Jul 2008 | Member Level: Gold | Rating:  Points: 2 |
Hi, try this..
insert test(name1,fname) select name1,fname from test
Hope this helps.. vino...
|
| Author: Bharathi 04 Jul 2008 | Member Level: Diamond | Rating:  Points: 3 |
because you have specified 'XYZ' which is like a value.
You should mention only the column names within the bracket and not the values. That is the reason the first query is not working and the second query does.
|
| Author: Ashok 04 Jul 2008 | Member Level: Gold | Rating:  Points: 1 |
Use this query.... INSERT INTO test(name1,fname)VALUES('ABC','XYZ') SELECT name1,fname FROM test
Please rate this post, if it is useful for you.
Thanks & Regards Ashok
|
| Author: Payal Jain 04 Jul 2008 | Member Level: Gold | Rating:  Points: 1 |
INSERT INTO test(name1,fname,'ABC' as <ur 3rd column name>) SELECT name1,fname FROM test
HTH
|