On 6/20/2012 9:35 AM, Walt Haas wrote:
> I'm not sure I understand your question.  In the example you give, you
> can get from the first table to the second table by just selecting the
> first two columns and ordering the result by product_id descending.  In
> other words your example doesn't use the product_id_map table at all.
>
> -- Walt
>
> On 06/20/2012 09:27 AM, Merrill Oveson wrote:
>> People smarter than me:
>>
>> Suppose I have the following table:
>>
>> product_id | product | product_id_map
>>       30         |   X        |  NULL
>>       29         |   A        |  30
>>       28         |   W       |  29
>>
>>
>> so product 28 "maps" to product 29 and product 29 "maps" to product
>> 30.  Product 30 is the beginning.
>>
>> The view I want would look like this:
>>
>> product_id | product
>>       30         |   X
>>       29         |   A
>>       28         |   W
>>
>> Possible to create a view using cursors to do this?  Or is there an easier 
>> way?
> _______________________________________________
>
> UPHPU mailing list
> [email protected]
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net

Or, if you want to get fancy with it...

http://explainextended.com/2009/07/20/hierarchical-data-in-mysql-parents-and-children-in-one-query/

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to