Help!!!
Hi!. Could you help with such a problem (please, refs to manuals, not RTFM!!!) I need to make a query to several tables. There's a DB Test with tables data, Table1,Table2...TableX
The structure of table data->
CREATE TABLE `date` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`date` date NOT NULL default '0000-00-00',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
UNIQUE KEY `date` (`date`)
)
The structure of Table1.... TableX is the same and looks like
CREATE TABLE `Table1` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`Field1` float(9,3) default '0.000',
`Field2` float(9,3) default '0.000',
`Field3` float(9,3) default '0.000',
`Field4` float(9,3) default '0.000',
`owner` bigint(20) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
)
where TableX.owner=date.id
Although it should be simple, this query to TableX with current id doesn't work.
The query:
SELECT date.id,Table1.Field11,Table2.Field1 // for example
FROM date RIGHT JOIN TABLE1 ON Table1.owner=date.id
RIGHT JOIN Table2 ON Table2.owner=date.id
WHERE date.id=(select MAX(id) from Test.date)
I need to get data with set, currently maximum id. There are 5 records in the table, but query returns 25. HEELP!.