Re: MySQL select matching

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 19 Jul 2010 10:36:40 -0600
"Ashley M. Kirchner" <ashley@xxxxxxxxxx> 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@xxxxxxxxxxxx>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux