MySQL group
am 17.09.2007 19:10:12 von jbl
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 help me?
Re: MySQL group
am 17.09.2007 19:25:00 von Shelly
"jbl" wrote in message
news:1190049012.382175.69020@n39g2000hsh.googlegroups.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 help 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
}
}
Re: MySQL group
am 18.09.2007 06:48:18 von jbl
> 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.
Re: MySQL group
am 18.09.2007 13:06:09 von Jerry Stuckle
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
==================