torifile
2008-11-09, 20:20
I set up an online registration system using drupal and ubercart. The setup worked perfectly and I'm very happy with the relative ease of getting it all working with google checkout. One deficiency of the setup has been the difficulty in getting the data OUT of the system.
I know that there's an easy mysql query I can use to get my data out, I just don't know what it is. Here's the situation:
uc_orders.uid matches up with users.uid to give me the name of the person who ordered the item.
uc_order_products.order_id matches with uc_order.order_id to give me the order number for that particular "item"'s order.
Each individual order has multiple rows in the uc_order_products table depending on the number of items ordered. I'd like to somehow collapse all these rows into columns so that each uid has a unique row.
Example:
User #1 orders items A, B, C and D. His order number is #12.
The uc_order table would have
uid order_id
1 12
The uc_order_products table would have
order_id product
12 A
12 B
12 C
12 D
What I'd like is to get a table that looks like this:
uid lastname order_id product product product product
1 Smith 12 A B C D
I've been able to get a join of all that data but I haven't been able to get it all one row. I realize that some people may have null values in one of the 4 product columns, but that's ok. Thoughts?
I know that there's an easy mysql query I can use to get my data out, I just don't know what it is. Here's the situation:
uc_orders.uid matches up with users.uid to give me the name of the person who ordered the item.
uc_order_products.order_id matches with uc_order.order_id to give me the order number for that particular "item"'s order.
Each individual order has multiple rows in the uc_order_products table depending on the number of items ordered. I'd like to somehow collapse all these rows into columns so that each uid has a unique row.
Example:
User #1 orders items A, B, C and D. His order number is #12.
The uc_order table would have
uid order_id
1 12
The uc_order_products table would have
order_id product
12 A
12 B
12 C
12 D
What I'd like is to get a table that looks like this:
uid lastname order_id product product product product
1 Smith 12 A B C D
I've been able to get a join of all that data but I haven't been able to get it all one row. I realize that some people may have null values in one of the 4 product columns, but that's ok. Thoughts?