Created
December 21, 2009 23:31
-
-
Save EvanCarroll/261354 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE inventory.vehicles AS v | |
SET date_sold = 'NOW' | |
WHERE v.date_sold IS NULL | |
AND EXISTS ( | |
SELECT * FROM temp_vehicles AS t | |
WHERE v.lot_id = t.lot_id | |
) | |
AND NOT EXISTS ( | |
SELECT * FROM temp_vehicles AS t | |
WHERE v.lot_id = t.lot_id AND v.vin = t.vin | |
); | |
UPDATE inventory.vehicles | |
SET lot_name = t.lot_name | |
, lot_id = t.lot_id | |
, comment_text = t.comment_text | |
, vin = t.vin | |
, stock = t.stock | |
, is_new = t.is_new | |
, make = t.make | |
, model = t.model | |
, model_no = t.model_no | |
, year = t.year | |
, price_retail = t.price_retail | |
, price_cost = t.price_cost | |
, price_invoice = t.price_invoice | |
, price_msrp = t.price_msrp | |
, price_special = t.price_special | |
, price_apr = t.price_apr | |
, price_term = t.price_term | |
, body = t.body | |
, trans_string = t.trans_string | |
, fuel = t.fuel | |
, trim = t.trim | |
, dealer_rep = t.dealer_rep | |
, is_certified = t.is_certified | |
, miles = t.miles | |
, vin_decode = t.vin_decode | |
, color_ext1 = t.color_ext1 | |
, color_int = t.color_int | |
, color_code_int = t.color_code_int | |
, color_code_ext1 = t.color_code_ext1 | |
, date_entered = t.date_entered | |
, engine_string = t.engine_string | |
, engine_displacement = t.engine_displacement | |
, engine_cylinders = t.engine_cylinders | |
, engine_configuration = t.engine_configuration | |
, date_sold = NULL | |
FROM temp_vehicles AS t | |
WHERE vehicles.lot_id = t.lot_id AND vehicles.vin = t.vin | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment