Re: Building WHERE SQL clauses
| From: | Stephen Wellington | Date: | Mon, 15 Sep 2008 17:33:04 +0000 |
| Subject: | Re: Building WHERE SQL clauses | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-45408@lists.php.net to get a copy of this message | ||
You probably want something like this:
SELECT * FROM chico as c, harpo as h WHERE c.operator = "Bill" OR c.operator =
"Jessica" OR h.operator = "Bill" OR h.operator ="Jessica"
However if those tables really are identical I would suggest having a
good look at your
database design to see if it can be normalised or something...
Stephen Wellington
On Mon, Sep 15, 2008 at 4:06 PM, Mike Sullivan <mjsulliv@uvm.edu> wrote:
> Hello all. I'm using PHP to build a query for a database that consists of
> multiple tables, all with identical attribues. A typical syntax try looks
> like this: SELECT * FROM chico, harpo WHERE operator = "Bill" OR operator =
> "Jessica"
>
> MySQL responds with this: Couldn't execute query.Column 'operator' in where
> clause is ambiguous
>
> I was hoping that since the tables are identical all I would need to do is
> list the attribute values not have to append them to the table names. Is
> there any way to do this? Perhaps with a setting in MySQL or a different
> syntax (JOIN, UNION, ...)? If not are there available some canned code
> snippets that build these types of strings from values passed in the $_POST
> array. Thanks for any insights on this. --- Mike
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Stephen Wellington
07956 042387
01865 280000 ext 12438
wellingtonsteve@gmail.com
steve@sjwwebdesign.co.uk
stephen.wellington@worc.ox.ac.uk