Jump to content

PHP Mysql find how many results it got

Joveice
Go to solution Solved by vorticalbox,
1 minute ago, Joveice said:

Yea but how can I use this for the mysql returns?

http://www.w3schools.com/sql/sql_func_count.asp

Hi, so I need a script that "select uid from user where team=somename".

In this database there are 3 users,

uid - jack, team - hello.

uid - river, team - hello.

uid - alex, team - no.

 

so when it runs the select to get all the usernames that has team hello in it I want it to return a number, in this case "2".

How can this be done?

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, corrado33 said:

I believe the keyword you are looking for is "count"

Yea but how can I use this for the mysql returns?

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Joveice said:

Yea but how can I use this for the mysql returns?

http://www.w3schools.com/sql/sql_func_count.asp

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, corrado33 said:

I believe it's just "select count(*)"

SELECT COUNT(players) where team='home';

 

that should di assuming you have the table called players and the column called team.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, vorticalbox said:

SELECT COUNT(players) where team='home';

 

that should di assuming you have the table called players and the column called team.

Thank you, works perfectly.

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×