Snippets Collections
claims_data['all-rejections'] = np.where(
        (claims_data['REJECTED'] > 0) | (claims_data['SIU_Rejected'] > 0), 1, 0)
# here we use WHERE column_name but we don't know what is the data 
# To fetch result of given string to match in column_data we use LIKE
#syntax SELECT * FROM <table-name> WHERE <column_name> LIKE '%<data-to-fetch>%' with out
#space both sides

SELECT * FROM employees WHERE department LIKE '%Clo%';
# NOTE : %Clo% is departement feches related data which start with that string

#ref below
course_data=# SELECT * FROM employees WHERE department LIKE '%Clo%' LIMIT 10;
 employee_id | first_name | last_name  |             email             | hire_date  |    department     | gender | salary | region_id
-------------+------------+------------+-------------------------------+------------+-------------------+--------+--------+-----------
           3 | Sydney     | Symonds    | ssymonds2@hhs.gov             | 2010-05-17 | Clothing          | F      |  95313 |         4
           7 | Ardeen     | Curwood    | acurwood6@1und1.de            | 2006-02-19 | Clothing          | F      |  28995 |         7
          10 | Redford    | Roberti    |                               | 2008-07-21 | Clothing          | M      |  72225 |         7
          21 | Bernardo   | Davage     |                               | 2013-07-11 | Clothing          | M      | 124949 |         6
          38 | Edna       | Erwin      |                               | 2003-04-09 | Children Clothing | F      |  91397 |         5
          48 | Birgitta   | Stanbrooke | bstanbrooke1b@netvibes.com    | 2016-09-12 | Clothing          | F      |  77259 |         1
          54 | Verney     | McQuirk    | vmcquirk1h@ning.com           | 2012-06-17 | Clothing          | M      |  97156 |         2
          55 | Norina     | Yea        | nyea1i@cnet.com               | 2005-06-14 | Children Clothing | F      |  45959 |         1
          56 | Wilek      | Cossor     | wcossor1j@merriam-webster.com | 2014-09-17 | Children Clothing | M      |  91859 |         4
          62 | Lek        | Camplin    |                               | 2007-07-16 | Children Clothing | M      | 124190 |         6
# so the scenario is we have table called employees
# in employees table there is column called department 
# there are different departments are included in table
# now we want some department which we dont know how its spelled there so we are just
# trying to fetch the data in column which matched or containes 
# ex: word 'Clothing' is in stored in table but we dont know exactly how data spelled there
# so we try to match something like '% clo %'
# or 'C% thing %'

SELECT * FROM emploees  WHERE department like '% thing %';
# or 
SELECT * FROM employees WHERE department like 'C% thing %';
star

Fri Aug 04 2023 07:30:22 GMT+0000 (Coordinated Universal Time)

#where #npwhere
star

Wed Feb 23 2022 10:49:25 GMT+0000 (Coordinated Universal Time)

#psql #like #select #where

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension