[PHP-DB] Multiple values in SELECT query

2008-03-09 Thread Ron Piggott
What is the correct syntax for where the results may be 1 or 2? What have I done wrong? SELECT * FROM table WHERE name LIKE ABC AND listing_type = 1 or 2 ??? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DB] Multiple values in SELECT query

2008-03-09 Thread Matt Anderton
I like the IN keyword: SELECT * FROM table WHERE name LIKE ABC AND listing_type IN ('1','2'); works kinda like PHP's in_array -- matt On Sun, Mar 9, 2008 at 1:34 PM, Ron Piggott [EMAIL PROTECTED] wrote: What is the correct syntax for where the results may be 1 or 2? What have I done

[PHP-DB] SELECT query from two tables

2008-03-09 Thread Ron Piggott
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

Re: [PHP-DB] SELECT query from two tables

2008-03-09 Thread Chris
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?

Re: [PHP-DB] SELECT query from two tables

2008-03-09 Thread Ron Piggott
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:

Re: [PHP-DB] SELECT query from two tables

2008-03-09 Thread Chris
Ron Piggott wrote: Two different rows Chris. That's the problem then. Your query is saying get records with category_reference of 10 and it has to have category_reference of 11 as well. No such rows exist. Maybe that should be an 'or' or 'in' (same thing). ...

Re: [PHP-DB] SELECT query from two tables

2008-03-09 Thread Bruce Cowin
I think what you mean to do is use IN(). And I would suggest table aliases. So it could look like this: SELECT * FROM ministry_directory md INNER JOIN ministry_directory_listing_categories mdlc ON md.entry = mdlc.ministry_directory_entry WHERE md.listing_type = 2 AND

Re: [PHP-DB] SELECT query from two tables

2008-03-09 Thread Ron Piggott
Thanks On Mon, 2008-03-10 at 12:56 +1300, Bruce Cowin wrote: I think what you mean to do is use IN(). And I would suggest table aliases. So it could look like this: SELECT * FROM ministry_directory md INNER JOIN ministry_directory_listing_categories mdlc ON md.entry =