From your first post, here is a simple solution to get all the rows where the list contains a 2:
dbadmin=> select * from dmp;
name | id | list
---------+------+-----------
asha | 2725 | [1,2,3,4]
vertica | 27 | [1,3,4]
jim | 43 | [2]
(3 rows)
dbadmin=> select * from dmp where list ilike '%2,%' or list ilike '%2]%';
name | id | list
------+------+-----------
asha | 2725 | [1,2,3,4]
jim | 43 | [2]
(2 rows)
The data in the LIST column of your DMP table in your example appears to be VARCHAR. I simply retrieved the rows where the string value of the column matches a specified pattern.
hii jim,
How do we store array of integers in vertica (not flex table) not in string form because for string form ilike operation working but it takes too much time.So if it possible to store array of integers please explain me with an example.
In the above example make that 'list' field as array
Comments
i tried but im getting like this ):
plzz provide solution
Hi,
From your first post, here is a simple solution to get all the rows where the list contains a 2:
hii jim
can you please explain that query to me , is ( , ) taking as % ??
thanku
The data in the LIST column of your DMP table in your example appears to be VARCHAR. I simply retrieved the rows where the string value of the column matches a specified pattern.
See: https://my.vertica.com/docs/8.1.x/HTML/index.htm#Authoring/SQLReferenceManual/LanguageElements/Predicates/LIKE-predicate.htm
From the documentation notice that you can specify what strings to match. This pattern to match can include:
hii jim,
How do we store array of integers in vertica (not flex table) not in string form because for string form ilike operation working but it takes too much time.So if it possible to store array of integers please explain me with an example.
In the above example make that 'list' field as array
Hi,
There is no array data type for a column in a standard table in Vertica.
Is the max size of the array known? You could create a separate INT column for each array element if you want to work with integers...
One Example:
Note that you can use FLEX table to flatten a JSON array out into unique columns.
See:
https://my.vertica.com/docs/8.1.x/HTML/index.htm#Authoring/FlexTables/FJSONPARSERreference.htm?Highlight=flatten_arrays
You can also create a view...