Jump to content

MySQL Select count all colums !=0


Recommended Posts

  • Active Member

I'm stuck on a query, i tried all the day to make it work

 

I want to count all pid1, pid2, pid3, pid4 from player.player_index with values > 0 or != to get number of total player for example: Total players chunjo

 

I'm trying to make this for website

 

Could anyone who knows to help me ?

Edited by Exygo
Link to comment
Share on other sites

Could you give me more details?

player_index idx ?????
player.player p ??????

​'p' is assigned to 'player.player' and 'idx' to 'player_index', what is so hard?

to make it work for each empire replace "EMPIRE_HERE" with 1/2/3

1 - red

2 - yellow

3 - blue

$qRedChars = mysql_query("SELECT COUNT(*) FROM player.player p, player.player_index idx WHERE p.account_id = idx.id AND idx.empire = 1");
$qYellowChars = mysql_query("SELECT COUNT(*) FROM player.player p, player.player_index idx WHERE p.account_id = idx.id AND idx.empire = 2");
$qBlueChars = mysql_query("SELECT COUNT(*) FROM player.player p, player.player_index idx WHERE p.account_id = idx.id AND idx.empire = 3");
  • Love 1
Link to comment
Share on other sites

  • Active Member

Could you give me more details?

player_index idx ?????
player.player p ??????

​'p' is assigned to 'player.player' and 'idx' to 'player_index', what is so hard?

to make it work for each empire replace "EMPIRE_HERE" with 1/2/3

1 - red

2 - yellow

3 - blue

$qRedChars = mysql_query("SELECT COUNT(*) FROM player.player p, player.player_index idx WHERE p.account_id = idx.id AND idx.empire = 1");
$qYellowChars = mysql_query("SELECT COUNT(*) FROM player.player p, player.player_index idx WHERE p.account_id = idx.id AND idx.empire = 2");
$qBlueChars = mysql_query("SELECT COUNT(*) FROM player.player p, player.player_index idx WHERE p.account_id = idx.id AND idx.empire = 3");

Could you give me more details?

player_index idx ?????
player.player p ??????

​you should read more about joining two tables here

https://dev.mysql.com/doc/refman/5.0/en/join.html

 

I apreciate your help guys, finished

P.S: I HAD SOME problems becouse my website was using mysqli bla bla bla

#Problem solved

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 0

      ImperiaWorld2 - SpeedServer - Opening 03/05/2024 - NewSchool - New Graphics M2 1.0.4b Terrain depth - International

    2. 2

      Very strange bug, when creating new char

    3. 6

      Voooxy aka m2core.tech scammer

    4. 117

      Ulthar SF V2 (TMP4 Base)

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / 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.