List:General Discussion« Previous MessageNext Message »
From:Johan De Meersman Date:May 18 2010 2:06pm
Subject:Re: Foreign Key Problem
View as plain text  
You're not specifying an engine, and the default is MyISAM, which doesn't
support foreign keys and will likely silently ignore requests for them. Can
you confirm that you've changed the default engine to InnoDB ?

On Tue, May 18, 2010 at 3:44 PM, Victor Subervi <victorsubervi@stripped>wrote:

> 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
>



-- 
Bier met grenadyn
Is als mosterd by den wyn
Sy die't drinkt, is eene kwezel
Hy die't drinkt, is ras een ezel

Thread
Foreign Key ProblemVictor Subervi18 May
  • Re: Foreign Key ProblemJohan De Meersman18 May
    • Re: Foreign Key ProblemVictor Subervi18 May
      • Re: Foreign Key ProblemJohan De Meersman18 May
        • Re: Foreign Key ProblemShawn Green18 May
          • Re: Foreign Key ProblemVictor Subervi18 May
            • Re: Foreign Key ProblemShawn Green18 May
              • Re: Foreign Key ProblemVictor Subervi19 May
                • Re: Foreign Key ProblemShawn Green19 May
                  • Re: Foreign Key ProblemVictor Subervi19 May
                    • Re: Foreign Key ProblemShawn Green19 May
                      • Re: Foreign Key ProblemVictor Subervi20 May
                        • Re: Foreign Key ProblemVictor Subervi22 May