Saturday, February 25, 2012

move database record

hi,

i have no problem to select all records from the table, but how to copy or move these selected records to other table which contain same field as the orriginal.

thanksINSERT INTO table2 (col1, col2, col3...)
SELECT col1,col2, col3
FROM table1
WHERE ...|||ndinakar, can u guide me more details. example i have one table call student, inside got id and name and move this record to a table call student2. can u guide me complete sql statement, because i new to the sql, i bit confuse in line 1 and line 2. thanks

INSERT INTO table2 (col1, col2, col3...)
SELECT col1,col2, col3

FROM table1
WHERE ...|||

INSERT INTO student2 (id,name)
SELECT id,name
FROM student
WHERE {something}

{something} could be ID=some number or name='some name' etc

|||is't this method is for one reord only? how about if i want to move 1000 records from table student to table student2 ?. thanks|||

You move as many records as your SELECT statement returns.

No comments:

Post a Comment