PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > MySQL group
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
MySQL group

Réponse
 
LinkBack Outils de la discussion
Vieux 17/09/2007, 18h10   #1
jbl
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut MySQL group

Hello.
I would like to select only changes in value:
time (datetime)
bits (integer)
in command:
select time,(bits>>8)&1 as P from VV order by time
I view this result:
time P
12:23:11 0
12:23:16 0
12:24:01 0
12:24:10 1
12:24:23 1
12:24:45 0
12:25:01 0
12:25:34 1
12:25:59 1

And how to obtain this result:
12:23:11 0
12:24:10 1
12:24:45 0
12:25:34 1

The group clause selects only two rows:
12:23:11 0 the first "0" value
12:24:10 1 the first "1" value

Can you me?

  Réponse avec citation
Vieux 17/09/2007, 18h25   #2
Shelly
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: MySQL group


"jbl" <jbl@profisystem.info> wrote in message
news:1190049012.382175.69020@n39g2000hsh.googlegro ups.com...
> Hello.
> I would like to select only changes in value:
> time (datetime)
> bits (integer)
> in command:
> select time,(bits>>8)&1 as P from VV order by time
> I view this result:
> time P
> 12:23:11 0
> 12:23:16 0
> 12:24:01 0
> 12:24:10 1
> 12:24:23 1
> 12:24:45 0
> 12:25:01 0
> 12:25:34 1
> 12:25:59 1
>
> And how to obtain this result:
> 12:23:11 0
> 12:24:10 1
> 12:24:45 0
> 12:25:34 1
>
> The group clause selects only two rows:
> 12:23:11 0 the first "0" value
> 12:24:10 1 the first "1" value
>
> Can you me?
>


I don't know how you could do this automatically with sql, but you could
foreach your way through the set, remembering the last P value and, if it
changes, then ooutput that row and reset the the remembered P value. Here
is some pseudocode.

P0 = 2;
foreach loop {
read next row from returned mysql query resource
get P and time from this row
if (P != P0) {
P0 = P;
output time and P
}
}




  Réponse avec citation
Vieux 18/09/2007, 05h48   #3
jbl
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: MySQL group

> Here is some pseudocode.
>
> P0 = 2;
> foreach loop {
> read next row from returned mysql query resource
> get P and time from this row
> if (P != P0) {
> P0 = P;
> output time and P
> }
>
> }

I'm using this solution, but on the client side.
If the connection is over the internet, this is
a very long way to get results.

  Réponse avec citation
Vieux 18/09/2007, 12h06   #4
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: MySQL group

jbl wrote:
>> Here is some pseudocode.
>>
>> P0 = 2;
>> foreach loop {
>> read next row from returned mysql query resource
>> get P and time from this row
>> if (P != P0) {
>> P0 = P;
>> output time and P
>> }
>>
>> }

> I'm using this solution, but on the client side.
> If the connection is over the internet, this is
> a very long way to get results.
>


This is not a MySQL group. This is a PHP group. Notice the name?

If you're asking MySQL questions, you need to be in a MySQL group. If
you're asking for a PHP solution, just what are you asking for?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  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 20h09.


Édité par : vBulletin® version 3.7.2
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
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09441 seconds with 12 queries