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
https://forums.phpfreaks.com/topic/262897-select-distinct-help-please/
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.

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();

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.