New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

Start a Discussion

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
Web Design and Hosting Creating sites, scripting, and hosting discussions.

long shot: php mysql column represent query?

Post Reply New Thread Subscribe

Thread Tools

Member Since: Jul 25, 2004
Location: Gaithersburg, MD
Posts: 389
gort is on a distinguished road
Mac Specs: Mac Pro 2.6ghz Quad Xeon, 23" Cinema

gort is offline
Here's an example:

we have two tables, one is called job_categories which has two columns:
job_category_id (integer, primary key, auto increment)
job_category_title (title of the job category)

second table is titled jobs, which is a list of jobs. One of the columns is job_category_id to correspond to the category it belongs in. Say we want to get a query that will list each job category title individually, and then how many jobs exist in the jobs table with that category_id. i.e

Architecture (3)
Human Resources (8)
Information Technology (0)
Miscellaneous (19)

Is there any way to do that query without having to do a count query individually on each row returned in some sort of a loop? I don't have any of my SQL books here (I'm at home with the family for Christmas, brought the powerbook with me).

I know it's a long shot asking here, but if anyone can offer a suggestion or point me to a better forum please let me know!
QUOTE Thanks

xstep's Avatar
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
You've probably resolved this by now. I'm not even sure exactly what you want, but...

select job_categories.job_category_title, jobs.job, count(*) mycount
from job_categories, jobs
where job_categories.job_category_id = jobs.job_category_id
group by job_categories.job_category_title, jobs.job;


If you could perform a loop through job_categories and use the id to find the jobs and count the result. I think maybe that is what you wanted to do, but I don't know how to do that in PHP.

Note: The syntax I used above will work in Oracle which I'm very familiar with, but you may need to use AS before mycount.
QUOTE Thanks

Post Reply New Thread Subscribe

« can you search for .mac webpages? | using iDisk to host files »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Starter
Last Post
Apache PHP MYSQL SQL timboellis Switcher Hangout 2 10-16-2005 08:43 PM
PHP mysql richardmojo Web Design and Hosting 2 05-09-2005 10:05 PM
mac os update 10.3.7 and PHP MYSQL lomokev Web Design and Hosting 2 01-27-2005 03:44 PM

All times are GMT -4. The time now is 02:18 PM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.

Welcome to

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!

(4 digit year)

Already a member?