Reply to PHP MySQL Query

Your name:

Reply:


Posted by Ridge Burner on 01/20/06 18:39

This is more of a MySQL question I believe, but I do not have any MySQL
newsgroups available to me here except a German one, so hopefully someone
can help me out here.

I have a table that holds events for people, and need to access specific
data for each person with a limit.

For example, I have 10 users who each have 6 events scheduled. I wish to
query for the next 3 events for each user. I can do it like so:

$sql = "SELECT * FROM myTable WHERE user='joe' ORDER BY timestamp ASC LIMIT
3";
$query = mysql_query($sql);
while($row = mysql_fetch_assoc($query)){
$myArray['joe'] = $row;
}

I can do this in turn for each user, no problem. However, I want to know if
I can put this into one SQL command like:

$sql = "SELECT first three records for each distinct user, ORDER BY
timestamp ASC";
(Yes, I know the syntax is wrong, it's just an example)

Hopefully this is possible and someone can help me out on this!

Thanks in advance!

--Ridge

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация