Snowflake Vs MS-SQL - Part 42 - Search Data

          


Search Data

A table contains multiple columns and if you want to search a particular word in any one of these columns.

Suppose you have data as below:
+---------------------------+-----------------+
| PLAY                      | CHARACTER       |
|---------------------------+-----------------|
| All Well That Ends Well   | KING            |
| Henry IV Part 1           | KING CLAUDIUS   |
| John John                 | CHATILLON       |
| King John                 | KING JOHN       |
| Lear Lear                 | GLOUCESTER      |
+---------------------------+-----------------+

Expected Output
+---------------------------+-----------------+
| PLAY                      | CHARACTER       |
|---------------------------+-----------------|
| All Well That Ends Well   | KING            |
| Henry IV Part 1           | KING CLAUDIUS   |
| King John                 | KING JOHN       |
+---------------------------+-----------------+



MS-SQL Server 

You can achieve this by using the LIKE & Wild Card as follows. 



In Snowflake, we can use the same approach as above however Snowflake has a different operation SEARCH.



If you want to search across all columns of the table then you can use as below.


For more details, you can refer to the following SEARCH.




Comments

Popular posts from this blog

Snowflake Vs MS-SQL - Part 36 - SPLIT_TO_TABLE

Snowflake Vs MS-SQL - Part 63 - ON Clause & Cross Join

Snowflake Vs MS-SQL - Part 33 - INITCAP