Robert Reed wrote:

Greetings.

I have a table that contains procedures and a table
that contains forms.  Each procedure may have 1 or
more forms or it may have no associated forms.  Each
form may be relevant to more than 1 procedure.  The
procedure table has 1 entry per procedure.  The forms
table may have more than 1 entry per form depending on
how many procedures use that form.  Each form entry
has a foriegn key tying it to the record number of the
procedure.

I want to compose a query that will pull out each
distinct instance of a form (in other words, no
duplicates) and then list which procedures use that
form

So: Form Name Procedure(s) Name

Something like:

  SELECT Form.Name, Procedure.Name
  FROM Form, Procedure
  WHERE Form.Procedure_id = Procedure.id
  ORDER BY Form.Name;

You'll have to substitute your actual table and column names, of course.

By the way, it appears that you have redundant data in your forms table. Normally, you'd make a forms table with one row per form, and a forms-to-procedures relation table with just the procedure and form keys.

Is this a clear enough explanation for folks?  I'm
willing to RTFM if somebody will point me to the
chapter(s) that discuss different join syntax and how
it's used in MySQL.  I'm using 3.23.54 in my
production environment at the moment and my tables are
MyISAM.

<http://dev.mysql.com/doc/mysql/en/SELECT.html> <http://dev.mysql.com/doc/mysql/en/JOIN.html>

Thanks in Advance

=====
Robert Reed

Michael


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to