Question: I have a table which contains two fields. The first is `name` of type `string`. The second contains one or more strings separated by comma (but it can contain a single string with no commas at all)

I want to construct a query to know if the string in the `name` field **does not** exist in **every** comma separated strings in the `names` field. 

Example 1: 

```
---------------------------------------------------------
name          names
---------------------------------------------------------
myname        xmyname,myname,mynamey

```

All the comma separated strings contain the word `myname`. So the query shoudl not return this row. 

But, Example 2:

```
---------------------------------------------------------
name          names
---------------------------------------------------------
myname        x,myname,mynamey

```

Should be returned. Because x does not contain myname.

The condition is that, if the string in the field `name` does not exists in **each** of the comma separated strings in the `names` field, then return the row.

This is not correct as this query will not return true in example 2 (which contains `x` which does not contain `myname`).

**IMPORTANT NOTE:**

1) There is not limit of how many commas there. It can be 0 commas or more. How to deal with this? 

2) The strings are variables. It is not always the case that the string is `myname`. Each row contains a different string in the `name` field.

Answer: 
Solution for Hive:

```
insert overwrite table laundry
select 
     item, wash1, 
     case when rn=1 then wash2
          else date_sub(wash2,1) 
      end wash2
from
(
select item, wash1, wash2,
       row_number() over(partition by item order by wash2 desc) rn  --latest=1 
  from laundry
)s;

```
In MYSQL DBMS,use like this simple code:

```
SELECT DATE_SUB("2017-06-15", INTERVAL 1 DAY);  

```

Set your column in the part one, like:

```
SELECT DATE_SUB(wash2, INTERVAL 1 DAY) 
from laundry
Where wash2 <> MAX(wash2); 

```

This function isn't work in the SQL server