PostgreSQL select jsonb key value from an array while joining tableMySQL : LEFT JOIN not fetching required...
How to limit sight distance to 1 km
Are there any modern advantages of a fire piston?
If I delete my router's history can my ISP still provide it to my parents?
Could a phylactery of a lich be a mirror or does it have to be a box?
Would a National Army of mercenaries be a feasible idea?
Writing a character who is going through a civilizing process without overdoing it?
Does SQL Server 2017, including older versions, support 8k disk sector sizes?
Why Prushim were the ones who "separated"?
It took me a lot of time to make this, pls like. (YouTube Comments #1)
Finding a mistake using Mayer-Vietoris
Early credit roll before the end of the film
Cookies - Should the toggles be on?
Measure of a Brownian motion = normal distribution?
How to prevent cleaner from hanging my lock screen in Ubuntu 16.04
Does paint affect EMI ability of enclosure?
Am I a Rude Number?
Can we use the stored gravitational potential energy of a building to produce power?
Why would space fleets be aligned?
Is my visa status for all destinations in a flight with connections checked in the beginning or before each flight?
Why did the villain in the first Men in Black movie care about Earth's Cockroaches?
My cat mixes up the floors in my building. How can I help him?
Advice for a new journal editor
Blindfold battle as a gladiatorial spectacle - what are the tactics and communication methods?
Why do no American passenger airlines still operate dedicated cargo flights?
PostgreSQL select jsonb key value from an array while joining table
MySQL : LEFT JOIN not fetching required dataPostgreSQL joining using JSONBPostgreSql JSONB SELECT against multiple valuesHow to get particular object from jsonb array in PostgreSQL?How to return value for key from a jsonb column?postgresql: how to define a JSONB column with default valuePostgreSQL 9.5 query performance depends on JOINed column in SELECT clausePostgreSQL JSONB update array elements queryFilter rows by objects in jsonb array in PostgreSQLJSONB Array of Strings (with GIN index) versus Split Rows (B-Tree Index)
I want to extract a string value from an object's key inside a jsonb array, coming from a table join_table which is left joined, meaning it could be empty for some values.
SELECT
t.id,
concat(t.content, array_to_string(jsonb_array_elements(j.arr)->'Name'->>0, ',')) AS content
FROM
main_table t
LEFT JOIN join_table j ON t.j_id = t.id
WHERE
t.id IN (1,2,3,4,...)
tables:
CREATE TABLE main_table (
id bigserial PRIMARY KEY,
j_id BIGINT,
content text
);
CREATE TABLE join_table (
id BIGSERIAL PRIMARY KEY,
arr JSONB
);
example of join_table.arr
[
{
"Id": 1,
"Name": "name1",
},
{
"Id": 2,
"Name": "name2",
}
]
What I am trying to achieve is to get concat a comma separated string of all the join_table.arr Name values
postgresql join json
New contributor
gadelkareem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I want to extract a string value from an object's key inside a jsonb array, coming from a table join_table which is left joined, meaning it could be empty for some values.
SELECT
t.id,
concat(t.content, array_to_string(jsonb_array_elements(j.arr)->'Name'->>0, ',')) AS content
FROM
main_table t
LEFT JOIN join_table j ON t.j_id = t.id
WHERE
t.id IN (1,2,3,4,...)
tables:
CREATE TABLE main_table (
id bigserial PRIMARY KEY,
j_id BIGINT,
content text
);
CREATE TABLE join_table (
id BIGSERIAL PRIMARY KEY,
arr JSONB
);
example of join_table.arr
[
{
"Id": 1,
"Name": "name1",
},
{
"Id": 2,
"Name": "name2",
}
]
What I am trying to achieve is to get concat a comma separated string of all the join_table.arr Name values
postgresql join json
New contributor
gadelkareem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I want to extract a string value from an object's key inside a jsonb array, coming from a table join_table which is left joined, meaning it could be empty for some values.
SELECT
t.id,
concat(t.content, array_to_string(jsonb_array_elements(j.arr)->'Name'->>0, ',')) AS content
FROM
main_table t
LEFT JOIN join_table j ON t.j_id = t.id
WHERE
t.id IN (1,2,3,4,...)
tables:
CREATE TABLE main_table (
id bigserial PRIMARY KEY,
j_id BIGINT,
content text
);
CREATE TABLE join_table (
id BIGSERIAL PRIMARY KEY,
arr JSONB
);
example of join_table.arr
[
{
"Id": 1,
"Name": "name1",
},
{
"Id": 2,
"Name": "name2",
}
]
What I am trying to achieve is to get concat a comma separated string of all the join_table.arr Name values
postgresql join json
New contributor
gadelkareem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I want to extract a string value from an object's key inside a jsonb array, coming from a table join_table which is left joined, meaning it could be empty for some values.
SELECT
t.id,
concat(t.content, array_to_string(jsonb_array_elements(j.arr)->'Name'->>0, ',')) AS content
FROM
main_table t
LEFT JOIN join_table j ON t.j_id = t.id
WHERE
t.id IN (1,2,3,4,...)
tables:
CREATE TABLE main_table (
id bigserial PRIMARY KEY,
j_id BIGINT,
content text
);
CREATE TABLE join_table (
id BIGSERIAL PRIMARY KEY,
arr JSONB
);
example of join_table.arr
[
{
"Id": 1,
"Name": "name1",
},
{
"Id": 2,
"Name": "name2",
}
]
What I am trying to achieve is to get concat a comma separated string of all the join_table.arr Name values
postgresql join json
postgresql join json
New contributor
gadelkareem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
gadelkareem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
gadelkareem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 4 mins ago
gadelkareemgadelkareem
1011
1011
New contributor
gadelkareem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
gadelkareem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
gadelkareem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
gadelkareem is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f231012%2fpostgresql-select-jsonb-key-value-from-an-array-while-joining-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
gadelkareem is a new contributor. Be nice, and check out our Code of Conduct.
gadelkareem is a new contributor. Be nice, and check out our Code of Conduct.
gadelkareem is a new contributor. Be nice, and check out our Code of Conduct.
gadelkareem is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Database Administrators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f231012%2fpostgresql-select-jsonb-key-value-from-an-array-while-joining-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown