[PHP-DB] begginer question

2005-09-03 Thread ziv gabel
Hi everyone
I just need something that I believe is very simple only I can't find an
answer for it anywhere

I have a database that each row has a machine, its serial, the customer and
other details. The problem is that I have customers with more than one
machine and I need to query for all the rows, but I don't want the rows that
contain duplicate customers.
The problem is that the only way for me to know the right row from let's say
3 rows that contain the same customer name is the serial number which needs
to be the higher.

So all I need a query to do that.

Thanks in advanced
Ziv

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



RE: [PHP-DB] begginer question

2005-09-03 Thread Miguel Guirao


First, you need to normalize your DB, maybe going up to the Third Normal
Form will give you a good DB design.
Second, there is a SQL parameter that let's you display only one record from
many duplicated records, equal records, I guess it is UNIQUE.

-Original Message-
From: ziv gabel [mailto:[EMAIL PROTECTED]
Sent: Sabado, 03 de Septiembre de 2005 02:35 p.m.
To: php-db@lists.php.net
Subject: [PHP-DB] begginer question


Hi everyone
I just need something that I believe is very simple only I can't find an
answer for it anywhere

I have a database that each row has a machine, its serial, the customer and
other details. The problem is that I have customers with more than one
machine and I need to query for all the rows, but I don't want the rows that
contain duplicate customers.
The problem is that the only way for me to know the right row from let's say
3 rows that contain the same customer name is the serial number which needs
to be the higher.

So all I need a query to do that.

Thanks in advanced
Ziv

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


Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta 
dirigido; contiene informacion estrictamente confidencial y legalmente 
protegida, cuya divulgacion es sancionada por la ley. Si el lector de este 
mensaje no es a quien esta dirigido, ni se trata del empleado o agente 
responsable de esta informacion, se le notifica por medio del presente, que su 
reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio 
este comunicado por error, favor de notificarlo inmediatamente al remitente y 
destruir el mensaje. Todas las opiniones contenidas en este mail son propias 
del autor del mensaje y no necesariamente coinciden con las de Radiomovil 
Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, 
afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos.

This message is for the sole use of the person or entity to whom it is being 
sent.  Therefore, it contains strictly confidential and legally protected 
material whose disclosure is subject to penalty by law.  If the person reading 
this message is not the one to whom it is being sent and/or is not an employee 
or the responsible agent for this information, this person is herein notified 
that any unauthorized dissemination, distribution or copying of the materials 
included in this facsimile is strictly prohibited.  If you received this 
document by mistake please notify  immediately to the subscriber and destroy 
the message. Any opinions contained in this e-mail are those of the author of 
the message and do not necessarily coincide with those of Radiomovil Dipsa, 
S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries 
companies. No part of this message or attachments may be used or reproduced in 
any manner whatsoever.

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



Re: [PHP-DB] begginer question

2005-09-03 Thread Micah Stevens


Select * from tablename group by customername order by serialnum DESC;

or

select distinct * from tablename order by serialnum DESC;


On Saturday 03 September 2005 12:34 pm, ziv gabel wrote:
 Hi everyone
 I just need something that I believe is very simple only I can't find an
 answer for it anywhere

 I have a database that each row has a machine, its serial, the customer and
 other details. The problem is that I have customers with more than one
 machine and I need to query for all the rows, but I don't want the rows
 that contain duplicate customers.
 The problem is that the only way for me to know the right row from let's
 say 3 rows that contain the same customer name is the serial number which
 needs to be the higher.

 So all I need a query to do that.

 Thanks in advanced
 Ziv

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



RE: [PHP-DB] begginer question

2005-09-03 Thread Bastien Koert


select max(serial_Num) from table where...

bastien


From: ziv gabel [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] begginer question
Date: Sat, 03 Sep 2005 21:34:31 +0200

Hi everyone
I just need something that I believe is very simple only I can't find an
answer for it anywhere

I have a database that each row has a machine, its serial, the customer and
other details. The problem is that I have customers with more than one
machine and I need to query for all the rows, but I don't want the rows 
that

contain duplicate customers.
The problem is that the only way for me to know the right row from let's 
say

3 rows that contain the same customer name is the serial number which needs
to be the higher.

So all I need a query to do that.

Thanks in advanced
Ziv

--
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



RE: [PHP-DB] begginer question

2005-09-03 Thread Bastien Koert


whoops forget the group by clause

select max(serial) from table
where clause
group by customer_id
order by...

bastien



From: ziv gabel [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] begginer question
Date: Sat, 03 Sep 2005 21:34:31 +0200

Hi everyone
I just need something that I believe is very simple only I can't find an
answer for it anywhere

I have a database that each row has a machine, its serial, the customer and
other details. The problem is that I have customers with more than one
machine and I need to query for all the rows, but I don't want the rows 
that

contain duplicate customers.
The problem is that the only way for me to know the right row from let's 
say

3 rows that contain the same customer name is the serial number which needs
to be the higher.

So all I need a query to do that.

Thanks in advanced
Ziv

--
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