postgresql-9.6

Querying Postgres 9.6 JSONB array of objects

ぃ、小莉子 提交于 2020-12-29 10:14:50
问题 I have the following table: CREATE TABLE trip ( id SERIAL PRIMARY KEY , gps_data_json jsonb NOT NULL ); The JSON in gps_data_json contains an array of of trip objects with the following fields (sample data below): mode timestamp latitude longitude I'm trying to get all rows that contain a certain "mode". SELECT * FROM trip where gps_data_json ->> 'mode' = 'WALK'; I pretty sure I'm using the ->> operator wrong, but I'm unsure who to tell the query that the JSONB field is an array of objects?

Querying Postgres 9.6 JSONB array of objects

限于喜欢 提交于 2020-12-29 10:14:35
问题 I have the following table: CREATE TABLE trip ( id SERIAL PRIMARY KEY , gps_data_json jsonb NOT NULL ); The JSON in gps_data_json contains an array of of trip objects with the following fields (sample data below): mode timestamp latitude longitude I'm trying to get all rows that contain a certain "mode". SELECT * FROM trip where gps_data_json ->> 'mode' = 'WALK'; I pretty sure I'm using the ->> operator wrong, but I'm unsure who to tell the query that the JSONB field is an array of objects?

Querying Postgres 9.6 JSONB array of objects

寵の児 提交于 2020-12-29 10:14:20
问题 I have the following table: CREATE TABLE trip ( id SERIAL PRIMARY KEY , gps_data_json jsonb NOT NULL ); The JSON in gps_data_json contains an array of of trip objects with the following fields (sample data below): mode timestamp latitude longitude I'm trying to get all rows that contain a certain "mode". SELECT * FROM trip where gps_data_json ->> 'mode' = 'WALK'; I pretty sure I'm using the ->> operator wrong, but I'm unsure who to tell the query that the JSONB field is an array of objects?

YYYY-MM column type in PostgreSQL

谁都会走 提交于 2020-11-29 08:20:36
问题 I need to a value associated to a month and a user in a table. And I want to perform queries on it. I don't know if there is a column data type for this type of need. If not, should I: Create a string field and build year-month concatenation (2017-01) Create a int field and build year-month concatenation (201701) Create two columns (one year and one month) Create a date column at the beginning of the month (2017-01-01 00:00:00) Something else? The objective is to run queries like (pseudo-SQL)

YYYY-MM column type in PostgreSQL

心不动则不痛 提交于 2020-11-29 08:20:01
问题 I need to a value associated to a month and a user in a table. And I want to perform queries on it. I don't know if there is a column data type for this type of need. If not, should I: Create a string field and build year-month concatenation (2017-01) Create a int field and build year-month concatenation (201701) Create two columns (one year and one month) Create a date column at the beginning of the month (2017-01-01 00:00:00) Something else? The objective is to run queries like (pseudo-SQL)

YYYY-MM column type in PostgreSQL

余生长醉 提交于 2020-11-29 08:19:56
问题 I need to a value associated to a month and a user in a table. And I want to perform queries on it. I don't know if there is a column data type for this type of need. If not, should I: Create a string field and build year-month concatenation (2017-01) Create a int field and build year-month concatenation (201701) Create two columns (one year and one month) Create a date column at the beginning of the month (2017-01-01 00:00:00) Something else? The objective is to run queries like (pseudo-SQL)

YYYY-MM column type in PostgreSQL

萝らか妹 提交于 2020-11-29 08:19:08
问题 I need to a value associated to a month and a user in a table. And I want to perform queries on it. I don't know if there is a column data type for this type of need. If not, should I: Create a string field and build year-month concatenation (2017-01) Create a int field and build year-month concatenation (201701) Create two columns (one year and one month) Create a date column at the beginning of the month (2017-01-01 00:00:00) Something else? The objective is to run queries like (pseudo-SQL)

YYYY-MM column type in PostgreSQL

牧云@^-^@ 提交于 2020-11-29 08:18:51
问题 I need to a value associated to a month and a user in a table. And I want to perform queries on it. I don't know if there is a column data type for this type of need. If not, should I: Create a string field and build year-month concatenation (2017-01) Create a int field and build year-month concatenation (201701) Create two columns (one year and one month) Create a date column at the beginning of the month (2017-01-01 00:00:00) Something else? The objective is to run queries like (pseudo-SQL)

YYYY-MM column type in PostgreSQL

喜你入骨 提交于 2020-11-29 08:18:34
问题 I need to a value associated to a month and a user in a table. And I want to perform queries on it. I don't know if there is a column data type for this type of need. If not, should I: Create a string field and build year-month concatenation (2017-01) Create a int field and build year-month concatenation (201701) Create two columns (one year and one month) Create a date column at the beginning of the month (2017-01-01 00:00:00) Something else? The objective is to run queries like (pseudo-SQL)

YYYY-MM column type in PostgreSQL

瘦欲@ 提交于 2020-11-29 08:18:24
问题 I need to a value associated to a month and a user in a table. And I want to perform queries on it. I don't know if there is a column data type for this type of need. If not, should I: Create a string field and build year-month concatenation (2017-01) Create a int field and build year-month concatenation (201701) Create two columns (one year and one month) Create a date column at the beginning of the month (2017-01-01 00:00:00) Something else? The objective is to run queries like (pseudo-SQL)