otuatail Posted September 3, 2009 Share Posted September 3, 2009 I have a table that logs every page a user looks at. It stores the IP address as well as the page being viewed. What I want is an SQL that shows IP address that only aperars once. I realise that IP address's are not static. The field in the table is `IP` Paul. Link to comment https://forums.phpfreaks.com/topic/172986-unique-records/ Share on other sites More sharing options...
kickstart Posted September 3, 2009 Share Posted September 3, 2009 Hi SELECT DISTINCT IP From SomeTable However not sure if you want just those where there is only a single row for an IP address SELECT IP, COUNT(*) AS IpCount FROM SomeTable GROUP BY IP HAVING IpCount = 1 All the best Keith Link to comment https://forums.phpfreaks.com/topic/172986-unique-records/#findComment-911698 Share on other sites More sharing options...
fenway Posted September 8, 2009 Share Posted September 8, 2009 You can do something similar with MAX() without incurring any HAVING performance penalties. Link to comment https://forums.phpfreaks.com/topic/172986-unique-records/#findComment-915018 Share on other sites More sharing options...
kickstart Posted September 9, 2009 Share Posted September 9, 2009 You can do something similar with MAX() without incurring any HAVING performance penalties. I think I must have brain fade as I cannot see how at the moment and I would prefer to avoid using HAVING. All the best Keith Link to comment https://forums.phpfreaks.com/topic/172986-unique-records/#findComment-915313 Share on other sites More sharing options...
fenway Posted September 10, 2009 Share Posted September 10, 2009 You can do something similar with MAX() without incurring any HAVING performance penalties. I think I must have brain fade as I cannot see how at the moment and I would prefer to avoid using HAVING. All the best Keith No, my turn for brain fade.... I didn't read the OP's question closely enough. Link to comment https://forums.phpfreaks.com/topic/172986-unique-records/#findComment-916303 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.