MySQL Forums
Forum List  »  Newbie

Help!!!
Posted by: Little_Cat Little_Cat
Date: April 05, 2005 12:20AM

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

Options: ReplyQuote


Subject
Written By
Posted
Help!!!
April 05, 2005 12:20AM
April 05, 2005 12:31AM
April 05, 2005 12:53AM
April 05, 2005 01:24AM
April 05, 2005 01:43AM
April 05, 2005 03:17AM
April 05, 2005 04:57AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.