View Single Post
  #3 (permalink)  
Old 11-03-09, 12:52 PM
m_abdelfattah m_abdelfattah is offline
Newbie Coder
 
Join Date: Sep 2004
Location: Alexandria, Egypt.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
The problem was because of not using LEFT JOIN, I did used LEFT JOIN and everything went fine.
Oh, sorry for this, Here's the Code :
Code:
SELECT `transactions`.*, `transaction_details`.*, `product_items`.`name` AS `product_name`, `branches`.`name` AS `branch_name` FROM `transactions`, `transaction_details`, `product_items`, `branches` WHERE `transactions`.`retailer_id` = '1' AND `transactions`.`transaction_id` = '5'
and I'd replaced it with :
Code:
SELECT `transactions`.*, `transaction_details`.*, `transactions`.`total_price` AS `transaction_total_price`, `transactions`.`original_total_price` AS `transaction_original_total_price`, `product_items`.`name` AS `product_name`, `branches`.`name` AS `branch_name`, `clients_suppliers`.`name` AS `client_supplier_name`, `users`.`name` AS `user_name`
    FROM `transactions`
    LEFT JOIN `transaction_details` on `transactions`.`transaction_id` = `transaction_details`.`transaction_id`
    LEFT JOIN `product_items` on `product_items`.`product_id` = `transaction_details`.`product_id`
    LEFT JOIN `branches` on (
        `branches`.`branch_id`= IF(`transactions`.`from_branch_id`>0,`transactions`.`from_branch_id`, `transactions`.`to_branch_id`)
                                                                                                    )
    LEFT JOIN `clients_suppliers` on `transactions`.`client_supplier_id` = `clients_suppliers`.`client_supplier_id`
    LEFT JOIN `users` on `transactions`.`user_id` = `users`.`user_id` 
    WHERE `transactions`.`retailer_id` = '1'
        AND `transactions`.`transaction_id` = '5'
Reply With Quote