1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Get all orders shipped to NY

Discussion in 'Databases' started by greatlogix, Feb 25, 2015.

  1. #1
    orders table have billing state filed and shipping state field. I need to get orders which were shipped to NY state. Suppose an order was billed and shipped to NY state. In this case billing_state field has value NY and ship_state is null. One order was placed from CA and shipped to NY. billing_state value is CA and ship_state is NY.
    SEMrush
    Now what should be the query to get both rows in result?
     
    greatlogix, Feb 25, 2015 IP
    SEMrush
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,630
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    
    SELECT * FROM table WHERE (billing_state = NY and shipping_state = null) OR shipping_state = NY;
    
    Code (markup):
    This should work - however, storing the shipping state as "null" is just stupid - why not just store it as the same as billing state if those two are the same?
     
    PoPSiCLe, Feb 25, 2015 IP