I have a SQLite file and I want to add 2550 empty (NULL) rows. I am able to add one empty line with this code But I need 2550 rows. Is there any shortcut for it? I don’t want to execute same code 2550 times. Answer If your version of SQLite support it, you could use a recursive CTE to
Tag: sql
SQL: Add multiple where clauses in a single query
I want to run an SQL query from Node.js. I am currently showing the total number of projects that have a specific status in each of the 4 quarters. What I want to do now is show the same result but while adding one more condition i.e, Fiscal Year. Here’s my code for the 4 quarters: This prints output in
Search for an email in an nvarchar column in SQL Server
I am looking to search for a particular email (e.g., fname@exmaple.com) in an nvarchar column in SQL Server. It should have been as easy as – However the above query is not covering one case. If the result set contains a Comment like “Comment from a user with email selfname@example.com”. In …
org.hsqldb.HsqlException: discrepancy in the number of rows counted
I’m trying to play around with an insecure application (Insecure Bank) and I’m trying to port it to secure it a bit more as a personal project. I have a problem inserting the contents of the database …
Pgsql find similar records in database
I have a table that has the layout of this sensor_id time value 1 2020-12-22 09:00:00 20.5 1 2020-12-22 10:00:00 21.5 1 2020-12-22 11:00:00 22.5 1 2020-12-22 12:00:00 23.5 2 2020-12-22 09:00:00 …
What is the best way to get a value from a reference table to update a foreign key relationship
I have a mapping table that maps an int to a string for example I have another table that references this one with a foreign key relationship create table products ( product_name varchar (50), …
Hive: group by calculated column
I need to execute query like select myUsualField, SOME_FUNCTION(myAnotherField) as myUnusualField from MYTABLE group by myUsualField, myUnusualField In Hive this query fails: it cannot find field …
SQLite – order by numbers inside string
its my first post here, so bear with me. I’m trying to order a query by numbers in a specific row that contain letters, using SQLite. Example: “Winter 1993”. I want to be able to sort by the …
Query only doing half of what I want
I have a function that is supposed to delete a product and, with it, delete its stock as well. But it keeps just deleting the stock. SSometimes I change the order of the querys and it shows an error that I can’t delete idproduto because its an FK, so I put the delete stock query first. It deletes the st…
Execute a query for multiple sets of parameters with psycopg2
I have a table that I want to query, but I want to make many specific queries and return a table of any results that have met their condition, and ignore queries that do not exist. Hopefully this illustrates what I’m trying to achieve here… I want to perform a series of select statements which eac…