Page 1 of 1

crazy query

Posted: Thu Nov 11, 2004 7:55 am
by magicrobotmonkey
Ok here is where I'm at. I have two tables, replies and jobs. I want a query that gets all the replies where the replytext equals one and I also want to get all the jobs. I'm not too familiar with SQLs conditional statements so I'm having some problems with this one. I'm trying something like

SELECT If RText = 1 THEN SUM(RText), COUNT(ReplyID), FROM...GROUP BY JobID

Obviously this is working. Is what I'm trying to do even possible?

Posted: Thu Nov 11, 2004 9:38 am
by neophyte
Might be, can you post the relevant tables and fields?

Try

Posted: Thu Nov 11, 2004 11:42 am
by AnarKy
Are these Tables Related?

If not, then you may select them in different queries,
If they are then you can select all of them,
and check those you want, in your actual script.

Im not really sure what your problem is,
but perhaps this will help.

Posted: Thu Nov 11, 2004 4:50 pm
by magicrobotmonkey
if anyone else has this question, i did it like this

Code: Select all

SELECT COUNT(IF(RText = 1,1,NULL)),COUNT(JReplyID) FROM Replies, Jobs Where Replies. JobID = Jobs.JobID GROUP BY Jobs.JobID
This gave me a total count of replies for each job alaong with a count of replies where the text was 1

then I foound out none of it mattered anyways...

Posted: Thu Nov 11, 2004 4:58 pm
by neophyte
My sympathies. :cry:

Nice query anyway! :wink: