Quote:
Originally posted by carley465
Ok but if I need to select only records from one table to the other table where the two table are joined do I need a where statement to do this???
|
If you choose to select ALL rows, then no you do not need a where statement. If you only wish to copy rows from one table based on a certain criteria, then yes.
Example:
Table employee
emp_id
ename
sal
job
Table developers
emp_id
ename
sal
job
ok - Employee holds all your employee data for every job. Table developers only holds data for your developers.
This is a bad example, but off the top of my head its good enough to get an idea.
If you want to copy all of the employees with developer jobs from EMPLOYEE to DEVELOPERS you would do something like this:
Code:
insert into developers (emp_id, ename, sal, job)
select emp_id, ename, sal, job from
employee where job = 'DEVELOPER'
This would effectively select all DEVELOPER records from EMPLOYEE and insert them into DEVELOPER. This is what I think you want to do correct?
Also should add a note to make sure the datatypes are consistent - dont try copying a date column to a varchar column... it makes the database angry
