Advertisement
Guest User

Untitled

a guest
May 28th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. CREATE TABLE stats
  2. (
  3. item character varying,
  4. data jsonb
  5. );
  6.  
  7. it contains values like
  8. ITEM DATA
  9. test1 [{"id":"1", "country":"UK"},{"id":"2", "country":"INDIA"}]
  10. test2 [{"id":"1", "country":"US"},{"id":"4", "country":"CHINA"},{"id":"5", "country":"CHINA"}]
  11.  
  12. SELECT * FROM company_products_stats_overseas_view t
  13. WHERE ( data @> '[{"country":"CHINA"}]')
  14. and t.product_name ilike '%test%';
  15.  
  16. output : [{"id":"1", "country":"US"},{"id":"4", "country":"CHINA"},{"id":"5", "country":"CHINA"}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement