Re: [PHP-DB] Conditional INNER JOIN

[email protected] (Ron Piggott)
Newsgroups php.db
Organization Acts Ministries Christian Evangelism
Message-ID <[email protected]>
This still isn't working; am I close?  

SELECT * FROM ( shopping_cart_orders INNER JOIN
shopping_cart_sales_shipping_address ON
shopping_cart_orders.shipping_address_reference =
shopping_cart_sales_shipping_address.reference ) CASE
shopping_cart_sales_shipping_address.same_as_customer WHEN
shopping_cart_sales_shipping_address.same_as_customer = '0' THEN INNER
JOIN shopping_cart_sales_billing_address ON
shopping_cart_sales_billing_address.shipping_address_reference =
shopping_cart_sales_shipping_address.reference

On Sat, 2008-05-24 at 19:40 -0400, Bastien Koert wrote:
> 
> 
> On 5/24/08, Ron Piggott <[email protected]> wrote: 
>         Is it possible to do a conditional INNER JOIN ?
>         
>         So far I have
>         
>         SELECT * FROM ( shopping_cart_orders INNER JOIN
>         shopping_cart_sales_shipping_address ON
>         shopping_cart_orders.shipping_address_reference =
>         shopping_cart_sales_shipping_address.reference )
>         
>         If shopping_cart_sales_shipping_address.same_as_customer has a
>         value of
>         "0" I need to
>         
>         INNER JOIN shopping_cart_sales_billing_address WHERE
>         shopping_cart_sales_billing_address.shipping_address_reference
>         =
>         shopping_cart_sales_shipping_address.reference
>         
>         otherwise the shipping address is the same as the billing
>         address.
>         Suggestions?
>         
>         Ron
>         
>         
>         
> 
> Ron,
>  
> you can't do conditional joins but you can use the CASE WHEN THEN
> structure to handle what you need. Check out the mysql docs for that
>  
> 
> 
> -- 
> 
> Bastien
> 
> Cat, the other other white meat
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.