Re: MySQL Group?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi John,

"John Taylor-Johnston" <John.Taylor-Johnston@xxxxxxxxxxxxxxxxxxxxx> wrote in 
message news:64.F3.14744.358A1E74@xxxxxxxxxxxxxxx
> Does anyone know of a good MySQL group?
> I want to make a relational link from `data` to `shopping` so when I 
> insert a new record in `shopping`, I will see the contents of
> `data`.`name` and `data`.`email` as a drop-down menu in `shopping`.
>
> Where does one go to get this kind of help?
>
> Thanks,
> John
>
>
> DROP TABLE IF EXISTS `data`;
> CREATE TABLE `data` (
>   `id` int(5) NOT NULL auto_increment,
>   `name` varchar(255) NOT NULL,
>   `email` varchar(255) NOT NULL default '',
>   PRIMARY KEY  (`id`)
> ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
>
> INSERT INTO `data` VALUES(1, 'Allen, Carolyn', 'nobody@xxxxxxxxxxxxxx');
> INSERT INTO `data` VALUES(2, 'Atwood, Margaret', 
> 'someone@xxxxxxxxxxxxxx');
>
> DROP TABLE IF EXISTS `shopping`;
> CREATE TABLE `shopping` (
>   `id` int(5) NOT NULL auto_increment,
>   `name` varchar(100) NOT NULL,
>   `address` varchar(100) NOT NULL,
>   `email` varchar(100) NOT NULL,
>   PRIMARY KEY  (`id`)
> ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
>
I'm not certain but think you need to include a 'references 
table_name(field_name)' clause that sets up the Foreign key relationship 
between the 2 tables. I think the Reference clause would replace the 
auto_increment in your primary key of the referencing table.

HTH
George 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux