Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --step one (no rows in original table shoud be affected.
- CREATE TABLE table3_data_feed_items AS
- SELECT
- id ,
- regexp_replace(offer_id, '([\x0000-\x001f])', '', 'g') as offer_id ,
- regexp_replace(offer_title, '([\x0000-\x001f])', '', 'g') as offer_title,
- regexp_replace(offer_description, '([\x0000-\x001f])', '', 'g') as offer_description ,
- regexp_replace(manufacturer, '([\x0000-\x001f])', '', 'g') as manufacturer ,
- price ,
- shipping_rate ,
- source ,
- regexp_replace(sub_category, '([\x0000-\x001f])', '', 'g') as sub_category ,
- regexp_replace(category, '([\x0000-\x001f])', '', 'g') as category ,
- regexp_replace(merchant, '([\x0000-\x001f])', '', 'g') as merchant ,
- regexp_replace(image_url, '([\x0000-\x001f])', '', 'g') as image_url ,
- original_price
- from data_feed_items
- where
- offer_description ~* '([\x0000-\x001f])'
- or offer_title ~* '([\x0000-\x001f])'
- or offer_id ~* '([\x0000-\x001f])'
- or manufacturer ~* '([\x0000-\x001f])'
- or sub_category ~* '([\x0000-\x001f])'
- or category ~* '([\x0000-\x001f])'
- or merchant ~* '([\x0000-\x001f])'
- or image_url ~* '([\x0000-\x001f])'
- ;
- update data_feed_items a
- set
- offer_id=b.offer_id,offer_title=b.offer_title,offer_description=b.offer_description,manufacturer=b.manufacturer,sub_category=b.sub_category,category=b.category,merchant=b.merchant,
- image_url=b.image_url
- from
- table3_data_feed_items b
- where a.id=b.id and
- (a.offer_id!=b.offer_id or a.offer_title!=b.offer_title or a.offer_description!=b.offer_description or a.manufacturer!=b.manufacturer or a.sub_category!=b.sub_category or a.category!=b.category or a.merchant!=b.merchant or
- a.image_url!=b.image_url) ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement