Help with the query selection from the table that contains the array field. It is necessary to output only those lines that do not contain an element in the array field. For example, Element- "C"

<table border=1> <tr><td>1</td><td>{A}</td></tr> <tr><td>2</td><td>{A,B}</td></tr> <tr><td>3</td><td>{A,B,C}</td></tr> <tr><td>4</td><td>{X,Y,Z}</td></tr> <tr><td>4</td><td>{C,D,E}</td></tr> </table> <br> 

So it is necessary that the request returns only the first, second and fourth lines.
I am writing to JAVA.

  • I correctly understood in your table the type of the field array of values? - jmu

2 answers 2

 select * from table where cell not like '%C%' 
  • Does this mean that I will not get a string in the cases of paCman and WarCraft - or8it
  • Well, according to the conditions of your task, these words are suitable, then everything is correct, if there are no such words there, then either control the data in the table or specify the sampling conditions - Gorets
  • While such a request is working, but over time, records AC, BC, etc. may appear. I wanted to know whether it is possible to check the specific elements of the array, and not the contents of the string. - or8it
  • did not understand =) - Gorets
  • one
    I think he checks the contents of the cell, if there is an array, he converts it to a string, and in it looks for similarities like - Gorets

9.17. Array Functions and Operators

 select * from table where not '{C}'::varchar[] <@ cell;