I am using HSQLDB for the database and have the following condition in which I have to avoid duplicate entries while joining 2 tables. Table1 HMEXPENSE +——–+—————+————-+ | …
Generically identify the rowid causing a constraint conflict in SQLite
I need to identify the row that caused a constraint check to fail after an INSERT OR IGNORE statement. I need this for a tool that generates SQL statements, so I can’t tie this to a specific use case …
How obtain a list of posts by category?
I have a MySQL table that associates articles with categories. Table “posts_categories”: postId – catId 178 4 177 4 176 4 175 4 174 4 171 4 170 4 169 4 168 4 167 4 166 4 165 4 164 4 163 4 …
Slow sql statement when using variables
I have the following SQL statement running against a MariaDB 10.1.26 with ~2.000 rows with instant results. When I use the following statement with variables for the datetime fields, the execution takes ~5.5 seconds. The more data rows I have, the longer it takes to execute the statement. Seems like the varia…
Execute MySQL’s SQL files using .NET
Whenever I make an update to my database (changes in stored procs, changes in tables, new tables ,etc.), I create a new sql file which I run on client’s computer via TeamViewer. I wanted my …
Returning multiple result sets from postgres: refcursors, functions or new features?
Premise: An entity has many children and grandchildren (gists, versions and files respectively, in this instance). When it (gist) is requested, we want its children (versions) and grandchildren (files for versions) as well. Here I am really pushing to do as much in SQL as possible, instead of composing severa…
sql group by – curse and blessing
I have 3 tables for a meal calculation. Now I like to find a meal by ingredient: Which give me a list like: Also I like to find meal by price like: Which give me a list like: Now let me build a query like Which gives me a list like: Because (i.price / i.minamount * r.quanitity) for this meal
MS SQL Join Two Tables with ‘IN’ Faces Problem
I have two tables for my system. Table 1: Book Table 2: BookStatus Now I want to find out the latest status of books that had been lent from 2018/11/05 to 201/11/10 and how many times they have …
Laravel Eloquent version of “NOT IN” SQL
Just need the Eloquent ORM format of this query.. giving a headache for a while. Answer You Can Try this. First you Can Select all Player IDs. $player_ids = TeamRequest::select(‘player_id’)->get(); Then you can find Players Player::whereNotIn(‘user_id’, $player_ids)->get();
How to make a foreign key on a different account
So I am currently using my account with username: ctxsys and a password In this account I have table named archiv11. In another account named d5a11 with a password I have a table called fileLocation …