Bluehost.com Web Hosting $6.95

Mess of a Query - Please help!

This is a discussion on Mess of a Query - Please help! within the MySQL Database forums, part of the Database Forums category; Hi. I'm trying to determine the number of unfilled jobs. An unfilled job in one where the number of ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-26-2007
lindsaytabas@gmail.com
 
Posts: n/a
Default Mess of a Query - Please help!

Hi. I'm trying to determine the number of unfilled jobs. An unfilled
job in one where the number of people needed for that job is greate
than the number of people assigned to that job. The table "jobs" has
information about that job, including a userID associated with an
employer, and a value NumPeopleNeeded which says how many people that
employer needs for that job. The table "job_assignment" has two
columns, JobID (associated with the job listing in table "jobs") and
UserID associated with an employee ID. I may have a job where I need
4 people and I have assigned 2 employees so far. So there would be 2
entries in "job_assignment" to reflect those two assigned employees.
This is my query to get the # of jobs that are unfilled:

select count(j.JobID) from jobs j left join job_assignment k on
(j.JobID = k.JobID) where j.userID='13' and
count(k.JobID)<j.NumPeopleNeeded;

mysql is telling me that it's an invalid use of a group function. any
ideas?

Reply With Quote
  #2 (permalink)  
Old 04-27-2007
Mitul
 
Posts: n/a
Default Re: Mess of a Query - Please help!

Try out something like this...

SELECT noofjobs-(SELECT count(*) from job_assignment as a WHERE
a.job_id=b.jobid) FROM jobs as b GROUP BY b.jobid

Reply With Quote
  #3 (permalink)  
Old 04-27-2007
Mitul
 
Posts: n/a
Default Re: Mess of a Query - Please help!

On Apr 26, 5:48 am, "lindsayta...@gmail.com" <lindsayta...@gmail.com>
wrote:
> Hi. I'm trying to determine the number of unfilled jobs. An unfilled
> job in one where the number of people needed for that job is greate
> than the number of people assigned to that job. The table "jobs" has
> information about that job, including a userID associated with an
> employer, and a value NumPeopleNeeded which says how many people that
> employer needs for that job. The table "job_assignment" has two
> columns, JobID (associated with the job listing in table "jobs") and
> UserID associated with an employee ID. I may have a job where I need
> 4 people and I have assigned 2 employees so far. So there would be 2
> entries in "job_assignment" to reflect those two assigned employees.
> This is my query to get the # of jobs that are unfilled:
>
> select count(j.JobID) from jobs j left join job_assignment k on
> (j.JobID = k.JobID) where j.userID='13' and
> count(k.JobID)<j.NumPeopleNeeded;
>
> mysql is telling me that it's an invalid use of a group function. any
> ideas?


Try out something like this...

SELECT noofjobs-(SELECT count(*) from job_assignment as a WHERE
a.job_id=b.jobid) FROM jobs as b GROUP BY b.jobid

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:06 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0