Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying with SQL

Status
Not open for further replies.

1510982

Programmer
Feb 17, 2002
57
SI
A simple question, I assume.
I'm looking for a solution with two tables that are with one-to-one relationship.

Patients
id | name | lastname

Heights
id | height

Now, I have already filled in the Patients table, but on the contrary Heights table is empty. Now I would want to copy all the Patients.id values to Heights.id. How would that be possible using SQL? Thank you for your answer.
 
insert into heights (id) select id from patients.

Note: This assumes that the height field either has a default or will accept a null value.
 
If height is not null column you can use:

insert into heights select id,175 from patients

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top