I am attempting to do a basic search in my sqlite3 database with this JavaScript: This works but is vulnerable to SQL injection. I am trying to get the sqlite replacements parameter to work but I cannot get the syntax right. Sqlite doesn’t want to replace anything within the string literal. What is the …
Is there a way to group by part of a datetime column in SQL?
I have a dataframe something like this. is there a way to return a table that sums the dollar values based on the time down to the minute. For example: Notice that the “time” data in the original data set spans over a few days but I am only concerned with the time of day. Thanks Answer I’m n…
Amazon Redshift join variable duplicated with select *
I’m trying to create a new table in Redshift The code used to create a new table works on it’s own but when I wrap it in create table it stops working Invalid operation: column name “Number” is duplicated; Any ideas what’s happening? I don’t want to specify every single col…
Search Engine Developement using MySQL relevancy, not working on PHP
i’m working on search engine developement. I’m kinda struggling with an SQL/PHP request. I’m trying to get the highest relevancy score from a search query. It works perfectly on SQL, but not at all on PHP, neither on localhost nor online (while the source code is generated by phpmyadmin itse…
Convert Postgres IPv6 column TEXT field into JSON
Trying to convert a text field to a JSON field in Postgres. The field was an IPv6 address those having multiple semicolons e.g.: “14:eth1:vTA1:::4:” Trying to run smth like: Results in: Failed to convert text field to JSON. Details: invalid input syntax for type json DETAIL: Expected end of input,…
MySQL – Slow query
Sorry for the long post, but the tables involved are quite big. When I run the query bellow it normally takes about 1m to run. However, when I remove the correlated sub-query I get the query down to 15 seconds. So I think that’s the actual problem. Problem is, I don’t really know how to get the SU…
Query with group by date
I’m working on the following user table, where role = 2 means the user is an instructor, and role = 3 means that the user is a student. My goal is to select the sum value of all instructors and students, grouped by date. The result should look like this: In this case, on 2020-07-01, I had 1 instructor a…
NoSQL or SQL for Data Structure [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question I’m building an app, and this is my first time working with databases…
Find a string inside a string and update in SQL Server
I have a table like this : I need to replace the string inside the tag c24 tag.. Excepted output: I need to replace the letter ‘G’ to be replaced with ‘T’ like this inside c24 tag – HT0010001 and all the rest should be same unchanged… What I tired: Answer If the code always…
How to optimize a SQL query that combines INNER JOINs and DISTINCT?
The query above returns me 5222 rows, and it runs locally in 0.63 seconds. I’m wondering if it is as fast as it can be or if I can tweak it further somehow, as this dataset will grow fast overtime. Things that I’ve tried without change in speed: 1 – Change the join order, joining from the sm…