MySQL Forums
Forum List  »  PHP

Query Problem
Posted by: Maik Kerner
Date: August 04, 2005 07:30AM

I have a problem by designing a query for mysql.

i have two tables like these one:

table1:

Number;ClientID;DateBeginn;DateEnd;Data
1;1;20050101;20050102;A
2;1;20050102;20050104;B
3;1;20050104;20050105;C

table2:

ClientID;Name;Surname;
1;Test;Test

I want to design three querrys:

The first one:
Give me for each client in table2 his name and surename and give me for this client the data in table2 which is the oldest one (from beginn)
Solution: 1;Test;Test;A

The second one:
Give me for each client in table2 his name and surename and give me for this client the data in table2 which is the newest one (from beginn)
Solution: 1;Test;Test;C

The third one:
Give me for each client in table2 his name and surename and give me for this client the data in table2 which difference (dateend - datebeginn) is the biggest.
Solution: 1;Test;Test;B

Can anybody help me to design these querys?

THX a lot

Options: ReplyQuote


Subject
Written By
Posted
Query Problem
August 04, 2005 07:30AM
August 04, 2005 07:51PM
August 04, 2005 07:53PM
August 04, 2005 09:41PM
August 04, 2005 09:43PM
August 06, 2005 12:50AM


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.