Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query

Status
Not open for further replies.

markstangroom

Technical User
Joined
Apr 25, 2001
Messages
96
Location
GB
I am trying to find a simple way PHP can extract data from a simple SQL table with just one select statement.

I have a field in a table intoo which users input a two letter code. There are forty of these codes.

What I want to do is count and get a total for each code.
i.e 24 AA's, 12 BB etc.

Is it possible to run one query "select * from subjectcode" and then get php to do the counting for each code?

Thanks
Mark
 
select your_code,count(your_code) from yourtable group by you_code;

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 

That wouldn't work in oracle, I'm not sure if it would work in mysql.

select your_code, count(0) from your_table
group by your_code;

 
definately works in mysql :-)

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top