[PHP-DB] SUMMARY: sorting problem...

2003-03-20 Thread guslist
Hello All,

Thanks for the all info !! I've done my query like this:

SELECT id,SUBSTRING(FROM_UNIXTIME(unixtime),1,10) as
unixtime,ip,porta_snmp,porta_switch,ip_cliente,mac_cliente from teste group
by unixtime,porta_switch,porta_snmp;

I've used SUBSTRING to get rid of the time from my unixtime... like this I
could get my resoults.

Thanks Alot,
Gus

- Original Message -
From: Snijders, Mark [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 14, 2003 11:25 AM
Subject: RE: [PHP-DB] sorting problem...


 hi,

 when you have them as unixtimestamp into your database it's impossible to
 group by this field, cause for every second this field is different...

 can you please try the output of this:

 select FROM_UNIXTIME(unixtimefield) from table

 and see if you now get back normal dates...

 if it;s work try this (don't know if its work, don't think so but try
it...
 and tell me the results)

 select FROM_UNIXTIME(unixtimefield) from table group by
 FROM_UNIXTIME(unixtimefield)

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: vrijdag 14 maart 2003 15:10
 To: Snijders, Mark
 Subject: Re: [PHP-DB] sorting problem...


 Hi,

 The problem is that using 'group by unixtime' I get back all my rows from
my
 table, once each record for unixtime is difrent (I save as UNIXTIME:
 1041949404).
 If I try to 'group by porta_snmp' I get back only uniq records... but I
have
 uniq records from day 2003-01-07 and 2003-02-07.

 Any help ?

 Thanks,
 Gus

 - Original Message -
 From: Snijders, Mark [EMAIL PROTECTED]
 To: 'Ignatius Reilly' [EMAIL PROTECTED]; [EMAIL PROTECTED];
 [EMAIL PROTECTED]
 Sent: Thursday, March 13, 2003 11:08 AM
 Subject: RE: [PHP-DB] sorting problem...


  guess you can better take a look at the group by function of mysql
 
 
 
  -Original Message-
  From: Ignatius Reilly [mailto:[EMAIL PROTECTED]
  Sent: donderdag 13 maart 2003 15:03
  To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
  Subject: Re: [PHP-DB] sorting problem...
 
 
  Take a look at the MySQL DATE_FORMAT() function.
 
  Ignatius
  
  - Original Message -
  From: [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Thursday, March 13, 2003 2:43 PM
  Subject: [PHP-DB] sorting problem...
 
 
   Hi All,
  
   I need to sort some data from a MySQL table. I have data saved like
 this:
  
   ++-++--+
   | id | unixtime| porta_snmp | porta_switch |
   ++-++--+
   |  1 | 2003-01-07 12:23:24 | 1614   | 1|
   |  2 | 2003-01-07 12:24:01 | 1614   | 1|
   |  3 | 2003-01-07 12:29:34 | 1614   | 1|
   |  4 | 2003-01-07 12:30:19 | 1614   | 1|
   |  5 | 2003-01-07 12:31:01 | 1614   | 5|
   |  6 | 2003-01-07 12:32:06 | 1614   | 5|
   |  7 | 2003-01-07 12:33:01 | 1614   | 1|
   |  8 | 2003-02-07 12:34:06 | 1614   | 1|
   |  9 | 2003-02-07 12:35:00 | 1614   | 1|
   | 10 | 2003-02-07 12:36:01 | 1614   | 1|
   ++-++--+
  
   I neet to sort the data to be able to read it better. In this case I
 just
   need to filter the data to get only the different info for each day.
 Some
   thing like this:
  
   2003-01-0716141
   2003-01-0716145
   2003-02-0716141
  
   Is this possible ?
  
   Thank's in advance,
   Gus
  
  
  
   --
   PHP Database Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 







-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] sorting problem...

2003-03-13 Thread guslist
Hi All,

I need to sort some data from a MySQL table. I have data saved like this:

++-++--+
| id | unixtime| porta_snmp | porta_switch |
++-++--+
|  1 | 2003-01-07 12:23:24 | 1614   | 1|
|  2 | 2003-01-07 12:24:01 | 1614   | 1|
|  3 | 2003-01-07 12:29:34 | 1614   | 1|
|  4 | 2003-01-07 12:30:19 | 1614   | 1|
|  5 | 2003-01-07 12:31:01 | 1614   | 5|
|  6 | 2003-01-07 12:32:06 | 1614   | 5|
|  7 | 2003-01-07 12:33:01 | 1614   | 1|
|  8 | 2003-02-07 12:34:06 | 1614   | 1|
|  9 | 2003-02-07 12:35:00 | 1614   | 1|
| 10 | 2003-02-07 12:36:01 | 1614   | 1|
++-++--+

I neet to sort the data to be able to read it better. In this case I just
need to filter the data to get only the different info for each day. Some
thing like this:

2003-01-0716141
2003-01-0716145
2003-02-0716141

Is this possible ?

Thank's in advance,
Gus



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] order by problem

2002-03-21 Thread guslist


Thank you all for the Tip ! It works fine now !! :)

Gus


- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Wednesday, March 20, 2002 10:32 AM
Subject: Re: [PHP-DB] order by problem


 On Wed, 20 Mar 2002 [EMAIL PROTECTED] wrote:

 You have your ctrlnumber field defined as varchar. If you define
 ctrlnumber as number, you could also use

 SELECT max(ctrlnumber) FROM table WHERE id=14;

 Cheers
 Urosh

  Hello All,
 
  Im having a 'problem' that I dont know how to resolve. The problem is:
 
  I have a table that I want to get the last number to increment. To do
this I
  want to sort the filed 'ctrlnumber'. Using this querys I get:
  mysql SELECT ctrlnumber FROM table WHERE id=14;
  ++
  | ctrlnumber |
  ++
  | 7  |
  | 1  |
  | 2  |
  | 3  |
  | 4  |
  | 5  |
  | 6  |
  | 8  |
  | 9  |
  | 10 |
  | 11 |
  ++
  11 rows in set (0.00 sec)
 
  mysql SELECT ctrlnumber FROM table WHERE id=14 order by ctrlnumber;
  ++
  | ctrlnumber |
  ++
  | 1  |
  | 10 |
  | 11 |
  | 2  |
  | 3  |
  | 4  |
  | 5  |
  | 6  |
  | 7  |
  | 8  |
  | 9  |
  ++
  11 rows in set (0.01 sec)
 
 
  When I try to sort, it doesnt return to me in the order that I need (1
2 3
  4 5 6 7 8 9 10 11). Is there a way to do this or Ill have to include 01
02
  03 04 05 to all my recoreds ?
 
  Thanks in advance,
  Gus
 
 
 


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] order by problem

2002-03-20 Thread guslist

Hello All,

I´m having a 'problem' that I dont know how to resolve. The problem is:

I have a table that I want to get the last number to increment. To do this I
want to sort the filed 'ctrlnumber'. Using this query´s I get:
mysql SELECT ctrlnumber FROM table WHERE id=14;
++
| ctrlnumber |
++
| 7  |
| 1  |
| 2  |
| 3  |
| 4  |
| 5  |
| 6  |
| 8  |
| 9  |
| 10 |
| 11 |
++
11 rows in set (0.00 sec)

mysql SELECT ctrlnumber FROM table WHERE id=14 order by ctrlnumber;
++
| ctrlnumber |
++
| 1  |
| 10 |
| 11 |
| 2  |
| 3  |
| 4  |
| 5  |
| 6  |
| 7  |
| 8  |
| 9  |
++
11 rows in set (0.01 sec)


When I try to sort, it doesn´t return to me in the order that I need (1 2 3
4 5 6 7 8 9 10 11). Is there a way to do this or I´ll have to include 01 02
03 04 05 to all my recoreds ?

Thank´s in advance,
Gus


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php