You are here: Optimizing SQL queries « PHP Programming Language « IT news, forums, messages
Optimizing SQL queries

Posted by Ridge Burner on 04/11/06 00:54

I currently have a DB with several rows of submitted items in it. There are
several items per user, but I am only interested in getting the first 3 for
each user. The script from the previous coder calls each query seperately,
but this is hard to maintain and I was hoping I could put this all in a
single SQL statement instead.

Right now the script queries for 3 rows from user #1 and stores in array,
then calls for next 3 from user #2 and stores in array etc etc.

I'm looking for a SQL statement like so:

$sql = "SELECT first 3 items for each UNIQUE user ORDER BY date_added ASC";

(yes, sql is wrong, its just an example to show what I want!)
I really hope this is possible, it would really cut down a lot of redundant
code we have now. I did look at MySQL site and PHP site, but could not find
anything that looked like it would do the trick.

Thanks in advance!

 

Navigation:

[Reply to this 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

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