List:General Discussion« Previous MessageNext Message »
From:Arthur Fuller Date:November 18 2002 2:13pm
Subject:RE: Problems with simple(?) query
View as plain text  
> SELECT * FROM foo WHERE id2=1 AND id2=2 (for example)...

Given your structure, no row can satisfy your criteria. You are asking ID2
to have two values on one row, which is clearly impossible. Did you by
chance mean:

	SELECT * FROM foo WHERE id2=1 OR id2=2
or alternatively
	SELECT * FROM foo WHERE id1=1 AND id2=2

Both these queries could return rows.

hth,
Arthur

-----Original Message-----
From: John Ragan [mailto:jragan@stripped]
Sent: Monday, November 11, 2002 9:38 PM
To: mysql@stripped
Subject: Re: Problems with simple(?) query


> Hi,
>
> I'm trying to write what I am sure should be a simple query, but just
can't get it to
> work!
>
> If I create a table called foo like this:
> create table foo ( id1 int(11) , id2(int 11) );
>
> populate it with data and then try:
>
> SELECT * FROM foo WHERE id2=1 AND id2=2 (for example),
>
> I just get an empty set returned. An explain on the query gives an
'Impossible WHERE'
> message.
>
> Both id1 and id2 can have duplicate values in them, though the same
combination of id1 and id2 cannot appear in the data (ie: id1=1, id2=1 ;
id1=1, id2=2 is possible,
> id1=1, id2=1 ; id1=1, id2=1 is not possible), and it is possible that the
values I
> search for will not be in the table at all.
>
> All I really want is to get the value for id1 where there are
corresponding records which match all of my search parameters for id2.
>
> Anyone got any ideas how to manage this? It's beginning to drive me mad!
>
> Thanks,
>
> James
>
>

to give the man a fish, or to teach him to fish.

if you have a windows box for a front end,
download corereader from http://corereader.com

it connects to any data source, and it likes
mysql a lot.  it does quick point and click
queries so you can, hopefully, find for yourself
the logic errors such as has been pointed out in
your query.

have fun.


--
        John Ragan
        john@stripped
        http://www.CoreReader.com/


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <mysql-thread124710@stripped>
To unsubscribe, e-mail <mysql-unsubscribe-afuller=etsys.com@stripped>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Thread
Problems with simple(?) queryJames Dyer11 Nov
Re: Problems with simple(?) queryDan Nelson11 Nov
RE: Problems with simple(?) queryPeter Grigor11 Nov
Re: Problems with simple(?) queryKeith C. Ivey11 Nov
  • Re: Problems with simple(?) queryMichael T. Babcock11 Nov
Re: Problems with simple(?) queryJohn Ragan12 Nov
  • How stable is MySQL 4.x vs 3.23.x?Jaime Teng12 Nov
    • Re: How stable is MySQL 4.x vs 3.23.x?Jeremy Zawodny12 Nov
  • RE: Problems with simple(?) queryArthur Fuller18 Nov
RE: How stable is MySQL 4.x vs 3.23.x?Kelly W [PCS] Black12 Nov