[PHP] Re: MySQL select matching

2010-07-19 Thread Michael Dykman
Not quite sure what the question is.

from:
> mysql> select * from table where id='1';
> +---+-+-+---+
> | 1 | 123 | 0.0 | C |
> | 1 | 234 | 0.1 | D |
> | 1 | 345 | 0.0 | D |
> | 1 | 456 | 0.1 | C |
> | 1 | 567 | 0.1 | G |
> +---+-+-+---+

How do we deduce that you would want ID '3' ?

This conversation would be easier if we gave names to those columns..

 - michael dykman


On Mon, Jul 19, 2010 at 12:36 PM, Ashley M. Kirchner  wrote:
>
>    I may be going at this completely wrong but at the moment I'm stuck.  I
> have a DB from a client and need to do several searches on it.  This one
> sentence is important because it's their DB, not mine.  So I can't modify
> the way the DB was created in the first place, I can only work with what I
> have.  And, whatever the solution to this might be, it does NOT have to be
> strictly MySQL, it can also be a PHP solution (which is why I'm sending it
> there as well.)  So, having said that, consider the following table:
>
> +---+-+-+---+
> | 1 | 123 | 0.0 | C |
> | 1 | 234 | 0.1 | D |
> | 1 | 345 | 0.0 | D |
> | 1 | 456 | 0.1 | C |
> | 1 | 567 | 0.1 | G |
> | 2 | 123 | 0.0 | C |
> | 2 | 234 | 0.1 | D |
> | 2 | 345 | 0.0 | D |
> | 3 | 234 | 0.1 | D |
> | 3 | 345 | 0.0 | D |
> | 3 | 123 | 0.0 | C |
> | 3 | 456 | 0.1 | C |
> | 3 | 567 | 0.1 | G |
> | 4 | 123 | 0.0 | C |
> | 4 | 234 | 0.1 | D |
> | 4 | 345 | 0.0 | D |
> +---+-+-+---+
>
> mysql> select * from table where id='1';
> +---+-+-+---+
> | 1 | 123 | 0.0 | C |
> | 1 | 234 | 0.1 | D |
> | 1 | 345 | 0.0 | D |
> | 1 | 456 | 0.1 | C |
> | 1 | 567 | 0.1 | G |
> +---+-+-+---+
>
>    Now, I have to find other IDs that match the above result.  In the table,
> that would be ID '3' (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 1, but the data is still the same.
>
>    So how do I efficiently search through the DB to find other IDs that
> matches the one I need?  I can't imagine doing a for loop selecting each ID
> and comparing their result to the one I'm starting with.  If the DB contains
> thousands upon thousands of rows, that might take a very long time.
>
>    Open to suggestions.
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=mdyk...@gmail..com
>
>



-- 
 - michael dykman
 - mdyk...@gmail.com

 May the Source be with you.

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



[PHP] Re: Mysql Select

2003-02-09 Thread andraskende
> Hello,
>
> Can anyone help me with this simple query:
>
> I want to limit to 1 the same names returned from the query like:
>
> 
>
> FROM:
>
> SELECT gallery.design FROM gallery
>
> buffet
> buffet
> buffet
> buffet
> barstools
> barstools
> barstools
> barstools
> barstools
> barstools
> barstools
> barstools
> tables
> tables
> tables
>
> 
>
> TO:
>
> SELECT gallery.design FROM gallery ??
>
> buffet
> barstools
> tables
>
>
> THANKS !!
>
> Andras Kende
> [EMAIL PROTECTED]




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