Ask a Question related to MySQL, Design and Development.
-
yawnmoth #1
select all users whose emails belong to two or more users
Say I wanted to create a query to select all the users whose emails
belong to two or more users. How would I go about doing this?
Here's what I have, so far (and which hasn't worked):
SELECT * FROM users WHERE email IN (SELECT email FROM users GROUP BY
email HAVING count(*) > 1))
Any ideas?
yawnmoth Guest
-
Select user for cam: no users in list
hey everyone i have setup flashmediaserver2 (win) and it connects and all that, but users arent appearing in the select user pulldown? i have opened... -
License.Limit.Exceeded with 4x150 users licence andonly 300 real users
As indicated by the ongoing discussion, this issue can have different causes - can you describe your application a little bit? How many users are... -
License.Limit.Exceeded with 4x150 users licence and only300 real users
We have 4x150 users licence, set to unlimited bandwith. We get these messages in event viewer: Connection rejected by server. Reason : :... -
Enable additional users properties in Active Directory users and Computers
"Mike Brannigan " <mikebran@online.microsoft.com> wrote in message news:O5qGXY1XEHA.808@tk2msftngp13.phx.gbl...... -
URL for example that allows users to select various items from list to print?
I remember seeing a couple of examples where the user could check several records for printing. I'm interested in the checking process so was... -
strawberry #2
Re: select all users whose emails belong to two or more users
yawnmoth wrote:untested> Say I wanted to create a query to select all the users whose emails
> belong to two or more users. How would I go about doing this?
>
> Here's what I have, so far (and which hasn't worked):
>
> SELECT * FROM users WHERE email IN (SELECT email FROM users GROUP BY
> email HAVING count(*) > 1))
>
> Any ideas?
SELECT t1.id, t1.username
FROM (
SELECT DISTINCT email, count( email )
FROM users
GROUP BY email
HAVING count( email ) >1
)t2
LEFT JOIN users t1 ON t1.email = t2.email
strawberry Guest
-
Bill Karwin #3
Re: select all users whose emails belong to two or more users
yawnmoth wrote:
Here's one possible solution:> Say I wanted to create a query to select all the users whose emails
> belong to two or more users. How would I go about doing this?
SELECT DISTINCT u1.*
FROM users AS u1 JOIN users AS u2
ON u1.email = u2.email AND u1.userid <> u2.userid;
Assuming userid is a primary key, or otherwise unique column.
Regards,
Bill K.
Bill Karwin Guest
-
yawnmoth #4
Re: select all users whose emails belong to two or more users
strawberry wrote:Thanks! :)> yawnmoth wrote:>> > Say I wanted to create a query to select all the users whose emails
> > belong to two or more users. How would I go about doing this?
> >
> > Here's what I have, so far (and which hasn't worked):
> >
> > SELECT * FROM users WHERE email IN (SELECT email FROM users GROUP BY
> > email HAVING count(*) > 1))
> >
> > Any ideas?
> untested
>
> SELECT t1.id, t1.username
> FROM (
>
> SELECT DISTINCT email, count( email )
> FROM users
> GROUP BY email
> HAVING count( email ) >1
> )t2
> LEFT JOIN users t1 ON t1.email = t2.email
yawnmoth Guest



Reply With Quote

