Jump to content

select distinct help please


Davie33

Recommended Posts

Hi am having a few problems solving this code with select distinct clause. None of what i tryed works.

Can anyone help please thanks.

 

this is just some of the query's i tryed

$query7 = yasDB_select("SELECT DISTINCT * FROM useronline WHERE id;");

$query7 = yasDB_select("SELECT DISTINCT ip FROM useronline WHERE id;");

$query7 = yasDB_select("SELECT DISTINCT ip FROM useronline WHERE ip;");

$query7 = yasDB_select("SELECT DISTINCT ip,timestamp FROM useronline WHERE id;");

$query7 = yasDB_select("SELECT DISTINCT id,ip,timestamp FROM useronline WHERE id;");

$query7 = yasDB_select("SELECT DISTINCT ip FROM useronline;");

 

and again but without ";"

 

$query7 = yasDB_select("SELECT DISTINCT * FROM useronline WHERE id");

$query7 = yasDB_select("SELECT DISTINCT ip FROM useronline WHERE id");

$query7 = yasDB_select("SELECT DISTINCT ip FROM useronline WHERE ip");

$query7 = yasDB_select("SELECT DISTINCT ip,timestamp FROM useronline WHERE id");

$query7 = yasDB_select("SELECT DISTINCT id,ip,timestamp FROM useronline WHERE id");

$query7 = yasDB_select("SELECT DISTINCT ip FROM useronline");

 

 

this is the code am working on.

$query7 = yasDB_select("SELECT DISTINCT * FROM useronline WHERE id;");
$visitors_online = $query7->fetch_array(MYSQLI_ASSOC);
$visitors_online = $query7->num_rows;
$query7->close(); 

visitors online : <?php echo $visitors_online;?><br/>

Link to comment
Share on other sites

If your just trying to get the unique id's, it's:

 

SELECT DISTINCT(id) FROM useronline

 

am trying to get the count working but nothin i do works

even when i try something like this

 

SELECT DISTINCT count(id) as count FROM useronline or SELECT DISTINCT count(id) as count FROM useronline WHERE id

 

Thanks on the query doesnt work tho thanks anyway.

Link to comment
Share on other sites

Hi its showing as only one online visitors online : 1 there is a few online atm

 

its odd man cos the code i was using works on test server localhost

which is this

 

$query7 = yasDB_select("SELECT DISTINCT ip,timestamp FROM useronline WHERE id;");
$visitors_online = $query7->fetch_array(MYSQLI_ASSOC);
$visitors_online = $query7->num_rows;
$query7->close();

Link to comment
Share on other sites

Hi iwould like to thank those who helped me in trying to solve this.The code works fine now as it was not the code that was the problem it was cos i missed out a file that should have been upload so i do apologize for that and thanks again people.

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.