Re: Conditional INNER JOIN

From: Date: Sat, 24 May 2008 23:40:25 +0000
Subject: Re: Conditional INNER JOIN
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-45003@lists.php.net to get a copy of this message
On 5/24/08, Ron Piggott <ron.php@actsministries.org> 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

« previous php.db (#45003) next »