Skip to content
Advertisement

How can I import a JSON file into PostgreSQL?

For example I have a file customers.json which is an array of objects (strictly formed) and it’s pretty plain (without nested objects) like this (what is important: it’s already include ids): And I want to import them all into my postgres db into a table customers. I found some pretty difficult ways when I should import it as json-typed column

how to split gender into two columns as male and female

I have simple table student which contains two column names and gender as m or f. I have to count number of male and female in table and display it into tow different columns . Result should be like: Answer I don’t know m but standard SQL for this would be :

How to Update new tables inside another update query?

I have a legacy system and i have a php file inside of it, updating one table. Now i added a new table to my db and i want to update that table too. The problem is that (for some reasons) i cannot use another query and i have to change the current query. simplified former query: $q = “UPDATE

One table with many field or two table with fewer fields?

My question is simple, currently, I have a database with an “User” table which contains important information about each users (email, username, password), an “Identity” table which contain the first name, last name, birthday… of an user, and a “Medias” table which currently contains fields like “facebook”, “googlePlus”, “twitter”, “youtube”… the address of all medias of the user actually. But,

Is there a LastIndexOf in SQL Server?

I am trying to parse out a value from a string that involves getting the last index of a string. Currently, I am doing a horrible hack that involves reversing a string: To me this code is nearly unreadable. I just upgraded to SQL Server 2016 and I hoping there is a better way. Is there? Answer If you want

Optimize GROUP_CONCAT in SQL on MySQL

Is there a way to get the following SQL optimized so it would run faster? I encountered the bottleneck are the GROUP_CONCAT’s but I couldn’t find a way by using an alternative or optimizing the query so it would run faster. At the moment the query needs about 3.2s on 2700 entries (mysql database 5.1.73, mysqli). All tables have indices

Advertisement