SELECT query from two tables
| From: | Ron Piggott | Date: | Sun, 09 Mar 2008 21:33:13 +0000 |
| Subject: | SELECT query from two tables | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-44731@lists.php.net to get a copy of this message | ||
I am wondering what is wrong with this syntax?
SELECT * FROM ministry_directory INNER JOIN
ministry_directory_listing_categories ON ministry_directory.entry =
ministry_directory_listing_categories.ministry_directory_entry WHERE
ministry_directory.listing_type = 2 AND
ministry_directory_listing_categories.ministry_directory_category_reference = 10 AND
ministry_directory_listing_categories.ministry_directory_category_reference = 11 ORDER BY
ministry_directory.name ASC
It produces 0 results.
In reality there is presently 1 record that should be found that has
listing_type = 2 and ministry_directory_category_reference 10 and 11 in
the ministry_directory_listing_categories table
The table "ministry_directory" has the main contact information. entry
is auto_increment; listing_type is an INT(1) column
The table ministry_directory_listing_categories has 3 columns:
reference which is auto_increment populated;
ministry_directory_entry which is the common field between both tables,
showing what the record belongs to &
ministry_directory_category_reference which is the reference number to
how the directory listing was inputted / categorized. (IE If the person
who completed the form select 2 of the 10 possible categories 2 records
were created.)
Is there a different way to word my query so I will be able to retrieve
the record with two rows in table ministry_directory_listing_categories
and 1 row in ministry_directory ?
Thanks for the help guys.
Ron