Linked Questions

234 votes
9 answers
488k views

I have two string columns a and b in a table foo. select a, b from foo returns values a and b. However, concatenation of a and b does not work. I tried : select a || b from foo and select a||', '|...
Alex's user avatar
  • 7,619
46 votes
3 answers
183k views

In PostgreSQL, I want to use an SQL statement to combine two columns and create a new column from them. I'm thinking about using concat(...), but is there a better way? What's the best way to do this?...
Rock's user avatar
  • 2,977
37 votes
2 answers
35k views

CREATE TABLE my_app.person ( person_id smallserial NOT NULL, first_name character varying(50), last_name character varying(50), full_name character varying(100) generated always as (...
ShadyBears's user avatar
  • 4,237
18 votes
2 answers
5k views

I am trying to index documents to be searchable on their tag array. CREATE INDEX doc_search_idx ON documents USING gin( to_tsvector('english', array_to_string(tags, ' ')) || ...
Jonathan Allard's user avatar
0 votes
1 answer
2k views

I'm trying to optimize these slow queries (excuse the SQL mixed with Ruby on Rails): WHERE name ILIKE %<the user's search text>% WHERE lower(NAME) LIKE :search OR lower(BARCODE) LIKE :search OR ...
Jack's user avatar
  • 5,464
2 votes
1 answer
2k views

in Postgres (Supabase) I am trying to automatically generate a column from another column which contains a text array of short title variants. The tsvector works just fine and as expected. The other ...
Kvetoslav's user avatar
  • 602
3 votes
3 answers
97 views

I tried to do the following: CREATE TABLE test_table ( column_1 varchar(255), column_2 varchar(255), combined varchar(255) DEFAULT concat(column_1, '_', column_2) ); It produces the ...
Cogito Ergo Sum's user avatar
3 votes
4 answers
221 views

I have a table CREATE TABLE IF NOT EXISTS club.climbers ( climber_id SERIAL PRIMARY KEY, climber_first_name VARCHAR(20) NOT NULL, climber_last_name VARCHAR(30) NOT NULL, ...
Юра Ковалeв's user avatar
1 vote
1 answer
261 views

I have a non-optimized query with ILIKE filters on 6 columns in the first table, and on one more column in the second table. There are more than 13 million records in the table. This request is ...
Alex Black's user avatar
1 vote
2 answers
55 views

I know that I can create an index that uses concatenation as follows: CREATE INDEX idx_table1_field1_field2 ON table1((field1 || field2)); But this is not quite what I need. I will try to explain ...
Ivan Yuzafatau's user avatar