Re: SELECT query from two tables
| From: | Ron Piggott | Date: | Sun, 09 Mar 2008 23:44:14 +0000 |
| Subject: | Re: SELECT query from two tables | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-44733@lists.php.net to get a copy of this message | ||
Two different rows Chris.
reference ministry_directory_entry ministry_directory_category_reference
13 1 10
14 1 11
What I am trying to do is allow the user to make a more specific search.
Ron
On Mon, 2008-03-10 at 10:37 +1100, Chris wrote:
>
> > ministry_directory_listing_categories.ministry_directory_category_reference = 10 AND
> >
> ministry_directory_listing_categories.ministry_directory_category_reference
> = 11
>
> Can a record really have a reference for two different id's like this?
> ie can it be both '10' and '11' at the same time?
>
> What's actually in the table for ministry_directory_listing_categories
> for this record?
>
>
> For long table names, I'd also suggest using a table alias to make it
> easier to read/write:
>
> select * from table1 as a inner join table2 as b using(id)
> where a.field_name='1' and b.fieldname='5';
>
> saves you having to write out 'ministry_directory_listing_categories'
> and 'ministry_directory'.
>