Hi;
mysql> create table if not exists Passengers (id int unsigned auto_increment
primary key, foreign key (id) references Flights (flights_id), foreign key
(id) references Customers (customer_id), name varchar(40), weight
tinyint(3));
Query OK, 0 rows affected (0.00 sec)

mysql> select c.first_name, c.middle_name, c.last_name, c.suffix,
c.discount, p.flights_id from Customers c join Passengers p on
c.id=p.customer_id
where flights_id=1;
ERROR 1054 (42S22): Unknown column 'p.flights_id' in 'field list'
mysql> describe Passengers;
+--------+------------------+------+-----+---------+----------------+
| Field  | Type             | Null | Key | Default | Extra          |
+--------+------------------+------+-----+---------+----------------+
| id     | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| name   | varchar(40)      | YES  |     | NULL    |                |
| weight | tinyint(3)       | YES  |     | NULL    |                |
+--------+------------------+------+-----+---------+----------------+
3 rows in set (0.01 sec)

So, why didn't the foreign key get created? It exists as a primary key in
Customers. Please advise.
TIA,
Victor

Reply via email to