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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL TO CREATE A RELATIONSHIP 1

Status
Not open for further replies.

hbez

Instructor
Mar 25, 2003
49
ZA
I have two existing but currently unrelated tables. Within a Delphi programme I have tried
ALTER TABLE tblFlights (Airplane TEXT(20) REFERENCES tblAircraft(Airplane));
and variations on this theme, but I keep getting a syntax error. Airplane is the key field in the table tblAircraft and I want to set up a 1-many relationship to the Airplane field in the table tblFlights.
Using the line in a CREATE TABLE statement works fine, but I need to use a separate procedure to set the relationship after the tables already exist.
My SQL knowledge is somewhat sketchy so I would really appreciate help with this one.
 
ALTER TABLE tblFlights ADD CONSTRAINT NameOfConstraint FOREIGN KEY Airplane REFERENCES tblAircraft(Airplane)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top