PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > Selecting just 'N' first rows
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Selecting just 'N' first rows

Réponse
 
LinkBack Outils de la discussion
Vieux 09/09/2007, 16h05   #1
Renito 73
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Selecting just 'N' first rows

Hello

How can I send a query that retrieves only the first 'N' rows that match a
condition? As far as I know you must call mysql_fetch_row() until the last
row has been processed or the resources allocated won't be free.

Am creating a program in PHP that should retrieve only 'N' records each time a
query is sent, so I I'm thinking on using mysql_free_result(), but, is it
safe to free the results even if there are more records remaining that match
the query conditions?

I need to know how secure could be to read only the first records and free the
resources, or if there is another way to do the same thing.

Thanks,
Miguel

  Réponse avec citation
Vieux 09/09/2007, 16h34   #2
Terry Riley
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Selecting just 'N' first rows

Look up the LIMIT clause of SELECT statement, also ASCENDING/DESCENDING
- depending on how you want it. Remember LIMIT can take a number and an
offset.

Terry

----- Original Message -----

> *From:* Renito 73 <renito73@gmail.com>
> *To:* mysql@lists.mysql.com
> *Date:* Sun, 9 Sep 2007 10:05:52 -0500
>
> Hello
>
> How can I send a query that retrieves only the first 'N' rows that
> match a condition? As far as I know you must call mysql_fetch_row()
> until the last row has been processed or the resources allocated
> won't be free.
>
> Am creating a program in PHP that should retrieve only 'N' records
> each time a query is sent, so I I'm thinking on using
> mysql_free_result(), but, is it safe to free the results even if
> there are more records remaining that match the query conditions?
>
> I need to know how secure could be to read only the first records and
> free the resources, or if there is another way to do the same thing.
>
> Thanks,
> Miguel
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=moscow@cix.co.uk
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.485 / Virus Database: 269.13.10/995 - Release Date:
> 08/09/2007 13:24
>
>



Terry
http://booksihaveread.awardspace.co.uk


--
No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.485 / Virus Database: 269.13.10/995 - Release Date: 08/09/2007 13:24


  Réponse avec citation
Vieux 09/09/2007, 16h41   #3
Christoph
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Selecting just 'N' first rows

> How can I send a query that retrieves only the first 'N' rows that match a
> condition? As far as I know you must call mysql_fetch_row() until the last
> row has been processed or the resources allocated won't be free.
> Am creating a program in PHP that should retrieve only 'N' records each
> time a
> query is sent, so I I'm thinking on using mysql_free_result(), but, is it
> safe to free the results even if there are more records remaining that
> match
> the query conditions?
> I need to know how secure could be to read only the first records and free
> the
> resources, or if there is another way to do the same thing.


Why dont' you just use the LIMIT statement?

thnx,
Chris

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h01.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08738 seconds with 11 queries