I have working query: It returns total count for all columns that has code=1081 and 1082 in “Region” table. In “Region” table there is “code” row that has 5 different codes. It’s a primary key to GeograpicalAdministrativeAreas table. I need to calculate for each column separated amount (not only for 1081 and 1082 in total how it is now). So
Tag: javascript
How to use group by in sql? (I need sequelize)
I have But it fails with this error: Works fine without GROUP BY Answer The GROUP BY statement groups rows that have the same values into summary rows, in your case, it is the country_code. It is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result-set by one or more columns. That means, for expl
How to pass an SQL function on bulk insert query in node
I have to execute an INSERT INTO query using mysql or mysql2 in node.js The values passed into the query utilizes a spatial geometry function ST_GeomFromGeoJSON() on geoMap column which is of type GEOMETRY. Here is the simplified code: The above code does not work and throws the error Cannot get geometry object from data you send to the GEOMETRY
strapi with mysql running simple raw sql
Need to run this query in my test and unable to find the right syntax. This is no postgresql and mysql does not like hyphens in table names. Please suggest. Answer Simply don’t use not allowed characters, it makes the life much more easy. The backticks around the String, where implemented, so that theuser dind’t need to escapee single and
How to push value selected from db as first if it is equal with value in other column?
I am doing autocomplete query system for cities and I have problem, that I want to prioritize main city of region from another results showed for exact phrase for ex. “%Trenc%”. If city and region are the same, I would like to place it as first result and then everything other. Trencin Trenc My idea is create another column in
Get List of Users for a Specific Local Time
In my database, I have a list of users with the user ids and their UTC offset in minutes. It’s in a PostgreSQL database which I access through sequelize in my node application. For example: I want to create a query that, when run, gets me a list of users that have passed 12pm noon their local time. For example,
Converting a SQL query to SEQUELIZE
I am trying to wrap my head around creating this sequelize query. I have been able to create 2 separate queries where the ‘order by filter’ works and ‘aliases’ work, but not combined. This is what i currenty have in sequelize Answer You just need to use fn twice: in order and in attributes options: Also you can combine findAll
How to use a SQL Result in Discord.JS SelectMenus?
I am trying to add Options to a SelectMenu from a SQL request. My code is the following: My Console is giving me the following output: There are no Errors. Still Discord doesn’t add it. It looks like this: Discord View of the Select Menu I have no clue, what i did wrong. Please help me out. Thanks in advance
many to many relationship knex js
I am trying to fetch data from the database in this way: I want all the templates and those templates have an array of categories in it so the methode I am currently using currently I am doing this but the object doesn’t seem to alter. Answer You are not waiting for the promises to resolve. You should do: instead
If case within string in JavaScript with variable either inside quotation marks or NULL?
This question is difficult to title but easy to show. I would like to add multiple sets of values to an SQL insert such as this happens in a loop and thus the separation of insert string and values string. Now, what I want to happen is that if event.url contains a url it should insert the url as ‘https://www.example.com’