Skip to content
Advertisement

select users have more than one distinct records in mysql

For a table that holds the records of user’s webpages visiting behavior, how can I select users that visit more than one webpages.

The structure of this tables is:

I can count using:

It gives me the result like:

How can I excute query that gives me the final result like:

each is user that visit more than one DISTINCT webpages

Advertisement

Answer

just add having clause

but if you only what the ID

the reason why you are filtering on HAVING clause and not on WHERE is because, WHERE clause cannot support columns that where aggregated.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement