I have an ecommerce website and I have it set up that countries are split into different zones for shipping costs. I have 8 zones, these are all arrays of country codes, there can be no duplicates in …
Tag: arrays
What is the simplest way to put pass an array of values into a parameter of TVF
Objective: I would like to have a parameter in my function to allow the user to input a list of values. Ideally, the simplest solution … Note: I dont have permissions to create tables in dbs. …
How to query on multiple attributes in the same json object array?
I have a json array similar to this structure in a column of my database – { “id”: “123abc”, “Y/N”: “Y”, “Color”: “Purple”, “arr”: [ { “time”: 1210.55 “person”: “Sean” “action”: “yes” //…
How to add an array of objects to chartjs?
How to add an array of objects to chartjs.The controller of that view sends to the template twig an array through the variable {{cg}}. The way I am doing it I get an error that what I’m going through …
Fetching constraints in SQL database to JSON in PHP
Let’s assume I have the following database structure of car manufacturers and the corresponding cars: manufacturers: cars: The id column of manufacturers is the primary key and the manufacturer column of cars has the corresponding foreign key constraint. I’d like to produce the following JSON output using PHPs json_encode: To get the manufacturers and their founded_in I’d just perform: And
Can’t convert SQL VARBINARY to byte[] correctly and convert to Image in ASP.NET c#
Here is what I’m doing: public static MVC_Picture GetPictureRecord(int pictureID) { int pictureId = pictureID; MVC_Picture _picture = new MVC_Picture(); //object that stores name and array …
Can PostgreSQL JOIN on jsonb array objects?
I am considering switching to PostgreSQL, because of the JSON support. However, I am wondering, if the following would be possible with a single query: Let’s say there are two tables: Table 1) organisations: Table 2) users: Now I want to get a result like this (all i have is the ID of the organisation [1]): I know this is
Update key of object inside array of objects in jsonb column
I have a jsonb column called data. It is deeply nested and there’s a key which’s value is an array of objects: As you see, there are different forms of “b” key. My goal is to update all rows with “b:” and “b_” keys and set them to “b”. Answer This answer describes the way to rename an attribute of
Modifying the keys in a PHP array before sending to JSON
I am querying a SQL database and returning some values. What I have is Field1 and Field2 which come out with a list of dates (There may be up to 200 values/dates eventually). I then reformat the …
Postgresql, retrieve value for specific key from json array
I have Postgres JSONB array of objects, looking like this : This JSONB is a function argument. What is the most efficient way to retrieve skillLevel for skillId = “1”. I’ve tried to play with jsonb_array_elements but everything I’ve done so far is looking really messy. Answer In Postgres 9.4+ use the function jsonb_array_elements() in a lateral join: You can