MySQL Forums
Forum List  »  General

Compressing (and indicating) multiple rows
Posted by: David Chess
Date: August 13, 2013 09:39AM

Apologies if this is obvious, or a FAQ. I searched around for an answer, but may just not have known what to use as keywords. And my SQL expert is on vacation. :)

To reduce it to simplest form, I have two tables, let's call them "job" and "task", where "job" has fields like "jname" and "juser", and "task" has fields like "tid" and "jname" and "tpriority". jname is a foreign key pointing from "task" into "job".

There is _usually_ only one row in "task" for any given jname. But once in awhile there are two or more.

I'd like to make a relatively efficient query that will display, for each jname, the jname and juser fields, and then in the case where there is only one corresponding row in task would also display the tid and tpriority from that row. Where there are multiple rows in task for that jname, it would display "*" or something (and then the report would say "* job has multiple tasks, issue xyz for details").

I can do this on the client side with multiple queries, obviously, but I'd rather do it on the server if feasible. Examples / hints / advice very welcome!

DC

Options: ReplyQuote


Subject
Written By
Posted
Compressing (and indicating) multiple rows
August 13, 2013 09:39AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.