Sorting by data the lowest values
Posted by: Manny MMM
Date: June 02, 2010 12:19PM

Hi,
i've these 2 tables:

T1:
===
-id
-name
...

T2:
===
-id
-owner (==T1.id)
-property //in $
...

And i try to select all data from T1 and the data sort by the lowest property in table T2.

The data can be look in these tables e.g.:
T1:
===
id: 1
name: John
-
id: 2
name: Paul
-
id: 3
name: Mark

T2:
==:
id: 1
owner: 2
property: 1000
-
id: 2
owner: 2
property: 500
-
id: 3
owner: 2
property: 2000
-
id: 4
owner: 1
property: 3000
-
id: 5
owner: 3
property: 2000
-
id: 6
owner: 3
property: 1670

And i need get in output something like that:
1.) Paul - 500
2.) Mark - 1670
3.) John - 3000

I try to use this sql query:
SELECT T1.*, T2.property FROM T1 JOIN T2 ON T1.id=T2.owner WHERE T1.menu='. $variable. ' GROUP BY T2.owner ORDER BY T2.property, T1.date, T1.name

But this query isn't completely correctly :/

Thanks.

PS: 'menu' and 'date' are next names of cols in tables



Edited 1 time(s). Last edit at 06/02/2010 12:26PM by Manny MMM.

Options: ReplyQuote


Subject
Written By
Posted
Sorting by data the lowest values
June 02, 2010 12:19PM


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.