Re: MySQL select matching
| From: | Simcha Younger | Date: | Wed, 21 Jul 2010 06:55:07 +0000 |
| Subject: | Re: MySQL select matching | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-307052@lists.php.net to get a copy of this message | ||
On Mon, 19 Jul 2010 10:36:40 -0600
"Ashley M. Kirchner" <ashley@pcraft.com> wrote:
> mysql> select * from table where id='00001';
> +-------+-----+-----+---+
> | 00001 | 123 | 0.0 | C |
> | 00001 | 234 | 0.1 | D |
> | 00001 | 345 | 0.0 | D |
> | 00001 | 456 | 0.1 | C |
> | 00001 | 567 | 0.1 | G |
> +-------+-----+-----+---+
>
> Now, I have to find other IDs that match the above result. In the
> table, that would be ID '00003' (and in the entire DB, there may be
> others as well - I need to find all those IDs.) But, notice how ID 0003
> isn't in the same order as ID 00001, but the data is still the same.
>
select distinct id from
table where concat(b, c,
d) in (select concat(b,c,d from
table where id = '0001') AND id != '0001';
(untested)
--
Simcha Younger <simcha@syounger.com>