Re: MySQL Group?

From: Date: Thu, 20 Mar 2008 00:36:53 +0000
Subject: Re: MySQL Group?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-271865@lists.php.net to get a copy of this message
Hi John, "John Taylor-Johnston" <John.Taylor-Johnston@cegepsherbrooke.qc.ca> wrote in message news:64.F3.14744.358A1E74@pb1.pair.com... > 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@jtjohnston.net'); > INSERT INTO data VALUES(2, 'Atwood, Margaret', > 'someone@jtjohnston.net'); > > 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

« previous php.general (#271865) next »