Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sql]

Structured Query Language is a language for interacting with relational databases. Read the tag wiki's guidelines for requesting SQL reviews: 1) Provide context, 2) Include the schema, 3) If asking about performance, include indexes and the output of EXPLAIN SELECT.

0
votes
0answers
6 views

Dynamic “compilation” of SQL stored procedures

I have a stored procedure which is called to create ( "compile" ) temporary stored procedures, code below, based on whether a flag in a database record is set - the various sub-procedures such as ...
0
votes
0answers
14 views

Tracking when a column was last modified using a trigger (in SQL Server)

How can I improve the following code to track when an Azure SQL Database column value was last modified? ...
-2
votes
0answers
16 views

How to optimize summarization linq query? [on hold]

Any optimizations that I can apply to that summarization? It seems to be slowing down my sql server even tho I am getting max 10 results from the query because of the ...
0
votes
1answer
18 views

Items and invoices query

I have invoices, invoices_items, order, order_items. <...
1
vote
0answers
26 views

Helper class for ASP.net to return data from SQL server

My goal is to create a class that I can call from my webpages like this. Similar to a data access layer? ...
-1
votes
0answers
45 views

Bulk insert of employees into Oracle database [on hold]

I have data that is stored in a list of class Employee: ...
2
votes
0answers
25 views

SQL Database for Visitor Registration System

This is intended for a web-based application that allows someone to register visitors, assign their hosts, and indicate the dates in which they will be visiting. Imagine this scenario: I want to ...
-2
votes
0answers
30 views

MySql Store Procedure performance slow

Anyone, please Optimize the MySQL query? We are using a union, join and not in it is working slow. In mysql docs it is showing if we use not in clause the performance will slow so what we need to do ...
0
votes
1answer
61 views

PHP code for search page

Want to show you part of code that I wrote to process search request. User commit search by articles (codes) of products. The goal is to allow user write his search request to textarea element in any ...
1
vote
0answers
17 views

SQL self-join to label nodes on binary search tree

Would like feedback on my SQL (1) efficiency and (2) readability, and if the conditions I featured in my CASE statement could be transferred to a join, etc. Here'...
2
votes
1answer
68 views

Build a string for a search query

I am building a string for a search query and I think I am doing it the wrong way. So basically I have serveral textfields, dates, integers and so on in one form. On submit I am checking the forms if ...
0
votes
0answers
12 views

Window function in MySQL 8

I'm running the following query on my database: ...
0
votes
0answers
34 views

Using an N-Tier architecture for a dynamic CRUD user control system

I want to design a flexible dynamic system for a client with standard data-entry screens and CRUD UserControls I dont know whether ...
1
vote
2answers
60 views

ORM class for Posts

I'm new to PHP OOP and I'm making some tests. I have 2 classes: database and posts and the two interact with each other. Class Database: ...
0
votes
2answers
24 views

Bulkloading xml's into Oracle table

Intro We have some old(in my eyes) software at the place I work at the moment, Some stuff needs to be done manually, for instance we need to insert a XML file into a Oracle table, which will trigger....
2
votes
0answers
20 views

Get local datetime from UTC time

One of the app is inserting date in UTC format (column CreateDate). When reporting from this table, I used a difference in hours between the inbuilt ...
0
votes
1answer
85 views

Modify a column in 2 tables based on trigger

This is SQL Server 2008r2. First, here are some tables and data for test: ...
-1
votes
0answers
15 views

SQL if else statements with multiple select

I have a SP in SQl like below ...
2
votes
2answers
106 views

Add variable columns to INSERT statement

I'm learning SQL using python library pymysql. I wanted to make an INSERT statement that will update 3, 5 or 10 columns using the same code by just passing the ...
1
vote
0answers
13 views

Calculate BACKLOG_M_1

I need to calculate the BLACKLOG_M value corresponding to the Snapdate of the first of the month. It becomes a constant value repeated for each line of the month As it is explained in the picture: <...
0
votes
0answers
29 views

Doctrine Query with subquery

I'm wondering if this is the right way to have a subquery in Doctrine. I have two entities, one called User and one called Log. ...
0
votes
0answers
119 views

Syncing a table to a remote database

I want to sync the table every few minutes to a remote database. I want it to be as efficient as possible. I wrote this stored procedure that will only return rows that are added or removed after the ...
-1
votes
1answer
35 views

Validating region/state/province codes for different countries

I have a large table in which I store region/state/province codes (two letters) from different countries. I use these region codes further downstream for multiple process. One of the steps I do is a ...
5
votes
1answer
119 views

Polymorphic Data Socket Factory with Query Contingency Protocols in Python

I work on a small data team where we developed this tool when we began experiencing several job failures on our legacy big data systems. We have several data lakes, each with their own API, and until ...
2
votes
0answers
69 views

MySQL database schema for e-commerce website

I'm making an e-commerce site, using MySQL for storing data. ...
3
votes
1answer
30 views

Iterate between dates and INSERT values in a performant way

I have created a query that populates a datapoint with random values. The logic is simple: Iterate between the START and END dates and INSERT random values. I want from this query to be very ...
3
votes
1answer
104 views

SQL SP creating certificates for shipping

We ship large spools of copper wire and pallets of copper rod that have to meet specific chemical and mechanical requirements, this is what must be put on the certifications. I created an SP which ...
3
votes
1answer
56 views

Generating report columns from SQL query

I've written this class to create RapportColumn objects for each column that is written in the query. And I would like to get your feedback. The query that is ...
1
vote
1answer
64 views

New comments after a user's last comment

Edit: I've added everything I can... I have the following query, which gets the last comment from the user in a given topic, then I check in the while loop if there are newer comments. My problem is,...
3
votes
1answer
36 views

Static class for database access Java JDBC

I'm writing a small program to store data in a database (a discord bot mainly). I know cleaner ways of using dependency injections and DAO exist, but I haven't written a DAO (or the user class) and ...
2
votes
0answers
29 views

SQL query that extracts a topic keyword from article titles

I have a query like this to select the only row with title contains specific programming topics. ...
0
votes
1answer
22 views

Get chat message data from table, grouped by date

Giving the following table: ...
2
votes
1answer
84 views

PHP + PDO - Inserting data on the table with a loop

First of all i made a simple code to insert data on my table, with the information from this code i made a loop to insert data on another table for a notification system. I'm new to PHP and i think ...
1
vote
2answers
206 views

Using decorator and strategy pattern for dynamically generating SQL queries

This is a link to my application that actually runs on the design specified in the image. The idea behind the image is that the SubjectInfoViewer behaves as the ...
2
votes
2answers
205 views

Find all shortest paths between 2 nodes in a directed, unweighted, SQL graph

I want to find all shortest paths between a pair of vertices in a unweighted graph i.e all paths that have the same length as the shortest. The edges of the graph are stored in a SQL database. The ...
1
vote
0answers
19 views

Activity grouping and selection according to order and completion requirements

The problem consists of two categories of events (Work and Rest) which together form a complete set. The number of Work events is open-ended. The number of Rest events is fixed at three (3). The ...
2
votes
0answers
84 views

Simple web API that access sqlite database

This is a very simple web API for a school assignment, as a part of a bigger system. The web API returns a list of courses or a single course as json. I doubt that I will get any feedback on the code ...
2
votes
0answers
38 views

Upsert query using CTE in PostgreSQL 9.4

I have a generic pipeline in SnapLogic that logs the start time of the executions of a group of incremental jobs. Suppose, the log table is as follows. ...
0
votes
1answer
42 views

Updating 3 columns conditionally on a database table

I need to run this script to update the value of 3 columns based on certain conditions. Right now, this is what I have: ...
0
votes
1answer
48 views

Simple PHP project to store inputs in MySQL and output them

As my first simple PHP project, I've created a simple project that allows you to just enter your name and two numbers, where it displays them on the page and stores them in a database. It consists of ...
3
votes
0answers
28 views

SEDE query to calculate net migrations quarterly from ELU to ELL

Over on EL&U Meta, someone raised the question of how many net migrations there are to/from our sister site, ELL. The following SEDE query calculates the net migrations by quarter (...
0
votes
0answers
7 views

Dynamic Statement Executor

I've written a stored procedure in order to simplify the process of calling dynamically constructed MySQL statements: Implementation ...
1
vote
0answers
75 views

Kotlin DAO with Exposed: How to reduce redundancy in classes?

I'm writing a Kotlin app that uses Exposed (https://github.com/JetBrains/Exposed) as a SQL wrapper to write and read objects from databases. The problem I'm facing is that I end up with 3 classes ...
1
vote
1answer
36 views

Loop Through bitarray to retrieve subsets of that bitarray

Objective: I want to loop through a bitarray and store subsets of that bitarray in a table. Context: I have a bitarray with 48 elements where each element represent one hour. I want to look back 24 ...
2
votes
1answer
73 views

Repository of trainers

This is my first asp.net core web api and i did followed the Repository pattern but i don't know whether this approach is good practice. ...
1
vote
1answer
104 views

Inserting data into SQL-Server table dynamically

I know I can do all this via SSMA quite quickly, but I wanted to see if I could do it efficiently in PowerShell myself as a little project. Basically, the entire script takes tables from an Access ...
-5
votes
1answer
62 views

How to write SQL in a industry standard style [closed]

Here are the commands I ran to start setting up a database I need. ...
2
votes
0answers
31 views

SQL query for selecting count from grouped columns of latest records

I have this table on SQL: ...
0
votes
2answers
81 views

Use a comma-separated field in another SQL query

I was just wondering if there was a better way to write this block of code in php. I have a string with values separated by commas. I need to prepare that string to pass it on to the query using IN ...
1
vote
1answer
44 views