Re: [PHP] Check for doubleposts

2005-05-06 Thread Richard Lynch
On Tue, May 3, 2005 9:48 am, Fredrik Arild Takle said:
> what is the easiest way to check if a person i registered twice in a
> mysql-table. Lets assume that I only check if the last name is in the
> table
> more than once. This is in mysql 4.0 (subquery not an option).
>
> Do I have to use arrays and in_array. Or is there a more elegant solution?

If the GROUP BY and HAVING solution doesn't thrill you (and I thought it
was quite nice and elegant) you could go with Ye Olde Standard Answer:

select * from user_table as a, user_table as b where a.lastname =
b.lastname and a.user_id != b.user_id

You can use a.user_id < b.user_id to see only the one duplication.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



RE: [PHP] Check for doubleposts

2005-05-04 Thread Mark Rees
-Original Message-
From: Fredrik Arild Takle [mailto:[EMAIL PROTECTED] 
Sent: 03 May 2005 17:49
To: php-general@lists.php.net
Subject: [PHP] Check for doubleposts


Hi,

what is the easiest way to check if a person i registered twice in a 
mysql-table. Lets assume that I only check if the last name is in the
table 
more than once. This is in mysql 4.0 (subquery not an option).
---
How about 
SELECT lastname, count(lastname) 
FROM table 
GROUP BY lastname
HAVING count(lastname)>1 
--
Do I have to use arrays and in_array. Or is there a more elegant
solution?

Best regards
Fredrik A. Takle 

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

Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, 
Cisco, Sun Microsystems, 3Com

GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND AN 'ISO 9001 
2000' REGISTERED COMPANY

**

CONFIDENTIALITY NOTICE:

This Email is confidential and may also be privileged. If you are not the
intended recipient, please notify the sender IMMEDIATELY; you should not
copy the email or use it for any purpose or disclose its contents to any
other person.

GENERAL STATEMENT:

Any statements made, or intentions expressed in this communication may not
necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no 
content
herein may be held binding upon Gamma Global (UK) Ltd or any associated company
unless confirmed by the issuance of a formal contractual document or
Purchase Order,  subject to our Terms and Conditions available from 
http://www.gammaglobal.com

E&OE

**
**


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



[PHP] Check for doubleposts

2005-05-04 Thread Fredrik Arild Takle
Hi,

what is the easiest way to check if a person i registered twice in a 
mysql-table. Lets assume that I only check if the last name is in the table 
more than once. This is in mysql 4.0 (subquery not an option).

Do I have to use arrays and in_array. Or is there a more elegant solution?

Best regards
Fredrik A. Takle 

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