Gabriell Carter Gabriell Carter - 2 months ago 5
SQL Question

SQL - How do I exclude results from a table if they have the same data in two columns

For example, I have a Cargo Shipment table and within that table there are two columns; Origin and Destination. How would I make it so that any results I get from my select statement will be excluded if the values in these columns are the same?

To be more specific, I could have a row where both Origin and Destination equals 'Chicago', how would I exclude that row without also excluding rows that have either Origin or Destination as Chicago.

Answer
SELECT
    *
FROM
    Cargo
WHERE
    Origin != Destination