Skip to content

Instantly share code, notes, and snippets.

@robins35
Created December 17, 2015 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robins35/92e42463a376bac899bf to your computer and use it in GitHub Desktop.
Save robins35/92e42463a376bac899bf to your computer and use it in GitHub Desktop.
UPDATE listings
SET price = CAST(
REGEXP_REPLACE(
REGEXP_REPLACE(
REGEXP_REPLACE(details.value, 'k$|K$', '000', 'g'),
'\.[0-9]{2}$', '', 'g'),
'[^0-9]', '', 'g')
AS money)
FROM details
WHERE details.detailable_type = 'Listing'
AND details.detailable_id = listings.id
AND details.name = 'price';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment