Re: combining the results of mysql query and finding the unique tuples in php

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

 



On 1/7/2011 12:10 AM, Fahim M wrote:
Hi
I have a certain number of mysql tables(relation), say 50, some of them
having 5 fields and some with 6 fields. a particular search item may be
found in multiple tables with multiple rows. I am using a loop to find all
those.
My problem is I want to first combine all those results and then find all
the unique entries. (the query results may overlap).


What is the best way to do it?

If you're looking for unique results, do a UNION query for all the tables. You'll need to add a dummy field for the 5-field tables, and make sure the field names are the same (use <oldfieldname> AS <newfieldname> to make sure everything ends up the correct result column). UNION queries automatically remove duplicates.

  Toby

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



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux