PDA

View Full Version : table relationships dont work


alexwilliams57
11-25-06, 09:31 PM
I have a MyISAM database and I have two tables which I would like to join. The first table is called 'number' and has primary key 'ID'The second table
reads:

CREATE TABLE `number2` (
`numberID` int(11) NOT NULL auto_increment,
`ID` int(11) NOT NULL default '0',
`answer` varchar(15) NOT NULL default '',
PRIMARY KEY (`numberID`),
KEY `number` (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

This is valid syntax and the table is created. However are there some settings I need to change to allow me to run sql statements which join my tables??? as nothing is printed when I try to join them from a PHP script.

"SELECT number.name, number2.answer FROM number JOIN number2 ON number.ID = number2.ID"

Thanks

mitchind
11-26-06, 04:49 PM
The MySQL manual has many examples that are great to learn from.

try this:

SELECT number.name, number2.answer FROM number, number2 WHERE number.ID = number2.ID