Home Forums Programming General displaying 2 values when field same RE: displaying 2 values when field same

  • I think you will need to join on the stop table twice once for the stop_type of PU and once for the stop_type of SO. Something like below:

    SELECT o.rate,
    sPU.actual_departure,
    sPU.city_name,
    sPU.state,
    o.id,
    PickUpCIty = sPU.City_Name,
    Delivery =sSO.
    city_name
    FROM orders o
    RIGHT OUTER JOIN stop sPU ON o.id = sPU.order_id AND sPU.Stop_Type = 'PU' -- Pickup CIty 
    RIGHT OUTER JOIN stop sSO ON o.id = sSO.order_id AND sSO.Stop_Type = 'SO' -- Delivery City
    WHERE o.equipment_type_id = 'V'
    AND o.customer_id = 'BEACCOOH'
    AND o.status = 'D'; 

    You may need to make one or both of the joins to stop left joins.