Jump to content

mySQL help...


subhomoy

Recommended Posts

Suppose i have created a database and i have created a table by using the code below

CREATE TABLE `track` (

`id` int(6) NOT NULL auto_increment,

`tm` varchar(15) NOT NULL default '',

`ref` varchar(250) NOT NULL default '',

`agent` varchar(250) NOT NULL default '',

`ip` varchar(20) NOT NULL default '',

`ip_value` int(11) NOT NULL default '0',

`domain` varchar(20) NOT NULL default '',

`tracking_page_name` varchar(10) NOT NULL default '',

UNIQUE KEY `id` (`id`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;

 

and the script  to store the details in that database is below

$tm=time();

$ref=@$HTTP_REFERER;

$agent=@$HTTP_USER_AGENT;

$ip=@$REMOTE_ADDR;

$strSQL = "INSERT INTO track(tm, ref, agent, ip, tracking_page_name) VALUES ('$tm','$ref','$agent','$ip','$tracking_page_name')";

$test=mysql_query($strSQL);

 

i want to know that if i have 10 ip in that database out of which there are 3 ip's are same. is there any way in which it will show there are only 7 ip ( as 3 ip's are same)

 

Any help would be appreciated...

if possible can you provide the code.....

thanks in advance...

Link to comment
Share on other sites

So you want it to show only the 7 unique IP's?

 

 

SELECT ip FROM track GROUP BY ip HAVING COUNT(ip) = 1

 

 

Or you want to show all IP addresses, but only once per address? (8 in total)

SELECT ip, COUNT(ip) AS occurences FROM track GROUP BY ip

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.