mysql query question

mysql query question

am 05.02.2008 17:38:45 von Kiran Annaiah

--_23704e46-fdf9-45d6-83c0-c3a170063a74_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello Here is the query i want to run select * from TABLEA where chipid in(=
'1873031558') and chip_section in('A') but with multiple values of chipid =
and its corresponding chip_section values (i have about 3000 of them) selec=
t * from TABLEA where chipid in('1873031558', '1887262626') and chip_sectio=
n in('A','A') so the result should return only the rows which satisfy the A=
ND condition (1st chipid with 1st chip_section) , (2nd chipd with 2nd chip_=
section) BUt, the result just returns all rows which match chipid and ignor=
es the chip_section.
=20
Is this something that needs to be run as a loop using a stored procedure?
=20
=20
=20
=20
-K
____________________________________________________________ _____
Connect and share in new ways with Windows Live.
http://www.windowslive.com/share.html?ocid=3DTXT_TAGHM_Wave2 _sharelife_0120=
08=

--_23704e46-fdf9-45d6-83c0-c3a170063a74_--

Re: mysql query question

am 05.02.2008 18:04:26 von John ORourke

Not sure if this is on topic but here goes...

Kiran Annaiah wrote:
> chipid and its corresponding chip_section values (i have about 3000 of them) select * from TABLEA where chipid in('1873031558', '1887262626') and chip_section in('A','A') so the result should return only the rows which satisfy the AND condition (1st chipid with 1st chip_section) ,
You're not telling it what you think are are - you are saying:

..... where (chipid=X or chipid=Y or chipid=Z) AND (chip_section=A or
chip_section=B or chip_section=C)

You want to say:

..... where (chipid=X and chip_section=A) OR (chipid=Y and
chip_section=B) OR ....

My suggestion is make a temporary table with 2 columns listing chipid
and chip_section combinations that you want, then use a left join to
join that to the main table, and only select rows where the joined
values are not null - that will be a lot quicker too if you have an
index on both columns.

cheers
John


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org