Welcome Guest, Not a member yet? Register   Sign In
JOIN problem
#6

[eluser]underzen[/eluser]
[quote author="wowdezign" date="1262923649"]After re-reading your post:
Code:
SELECT `orders`.`id`, `orders`.`order_date`, `orders_items`.`order_id`, `orders_items`.`product_id`
FROM (`order_items`)
JOIN `orders` ON `orders_items`.`order_id` = `orders`.`id`
WHERE `orders`.`customer_id` = '19'

That should give you a result set containing the items. It will have repeated order.ids but it gives you the order_items grouped like you said, if I understood you right.[/quote]

First off, thank you so much for you help!

I tried the left join as you explained a few posts ago. That didn't work. I then tried changing the join around and I get the same exact result.

Code:
SELECT `orders`.`id`, `orders`.`order_date`, `orders_items`.`order_id`, `orders_items`.`product_id`
FROM (`orders_items`)
JOIN `orders` ON `orders_items`.`order_id` = `orders`.`id`
WHERE `orders`.`customer_id` = 19

The result is the same:
Code:
Array
(
    [0] => Array
        (
            [id] => 84
            [order_date] => 2010-01-04 15:07:00
            [order_id] => 84
            [product_id] => 1
        )

    [1] => Array
        (
            [id] => 84
            [order_date] => 2010-01-04 15:07:00
            [order_id] => 84
            [product_id] => 3
        )

    [2] => Array
        (
            [id] => 85
            [order_date] => 2010-01-07 13:24:02
            [order_id] => 85
            [product_id] => 1
        )

)




I can't seem to figure this out Sad


Messages In This Thread
JOIN problem - by El Forum - 01-07-2010, 03:12 PM
JOIN problem - by El Forum - 01-07-2010, 03:55 PM
JOIN problem - by El Forum - 01-07-2010, 04:00 PM
JOIN problem - by El Forum - 01-07-2010, 04:03 PM
JOIN problem - by El Forum - 01-07-2010, 04:07 PM
JOIN problem - by El Forum - 01-07-2010, 08:22 PM
JOIN problem - by El Forum - 01-07-2010, 09:29 PM
JOIN problem - by El Forum - 01-07-2010, 10:39 PM
JOIN problem - by El Forum - 01-08-2010, 07:52 AM
JOIN problem - by El Forum - 01-09-2010, 12:18 AM
JOIN problem - by El Forum - 01-09-2010, 01:55 PM
JOIN problem - by El Forum - 01-09-2010, 02:18 PM
JOIN problem - by El Forum - 01-10-2010, 10:34 AM
JOIN problem - by El Forum - 01-10-2010, 10:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB