Stack Exchange Network

Stack Exchange network consists of 175 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
3 views

Search by parameters from multiple tables

This query searches people based on search parameters from 3 other tables (phones, emails, <...
0
votes
1answer
40 views

Saving row versions in MySQL [on hold]

I just want to confirm that I am versioning my "versionable" fields correctly, and that there isn't another, better way to do this. I have a table event, a record ...
0
votes
0answers
18 views

Ensuring referential integrity in child, group relationship

I'm not going to lie - Sql Server is not in the top 10 of my skill set, but it's something that I have to do from time to time. What's more, I'm using Entity Framework, so there is a workaround ...
-5
votes
0answers
42 views

5 different inputs from same [closed]

im working with laravel and i want to ask you how can i insert more then one different input data from 1 form to same table field, for example: I have that 2 migrations: ...
1
vote
0answers
36 views

Running an UPDATE SQL QUERY within VBA using DAO

I have a macro in Excel that updates a recordset using WHERE a primary key in MS Access matches a primary key in a UserForm label value. The macro is called from a ...
4
votes
2answers
64 views

Database Model Security For Book Inventory

This code is one of the models developed for the Book Inventory application that is open for review. It is also based on a comment on this answer to a C# question. Based on the comment I did some ...
3
votes
0answers
17 views

spark takes long time for checking an array of items present in another array

I am new to spark. I have two dataframes df1 and df2. df1 has three rows. df2 has more than few million rows. I want to check whether all items in df2 are in transaction of df1, if so sum up the costs....
2
votes
1answer
75 views

Web Server handler class to pass IIS http requests to SQL Server stored procedures

This is a c# class I use to implement web database applications with Microsoft IIS and Microsoft SQL server. It passes the http context to a selected SQL stored procedure, and writes a response based ...
1
vote
0answers
18 views

Fetching SQL table names and dynamicly insert values

I need to make a UI where I can edit/insert/remove records of my SQL tables through my app. Edits and deletes of records works fine except of insertions when it comes to tables with auto-incremented ...
1
vote
1answer
33 views

Listing people with their phone numbers (if any)

I have the following tables in my database: ...
0
votes
1answer
30 views

Simple join between 2 tables with unusual structure

I have two tables ACCOUNTS: ...
1
vote
1answer
35 views

Read comma separated values and insert in SQL Server 2016 table using String_Split

I know that this question has been asked many times over many years and I have read every one of them but I wanted to get a modern solution since software has changed and ...
2
votes
0answers
32 views

SQL Query - records within the last year

Bit of a complicated one for me. I have a database full of hundreds of thousands of records, many of which are duplicated. I need to get all records within the last year but making sure every ...
0
votes
0answers
13 views

Optimize slow SQL stored procedure that calculate Test Case failures in a non-optimal schema

I need to heavily optimize the following sql stored procedure (MySQL 5.6). Requirements: Should be as fast as possible (this is a key) Lots of records (10 M now, possibly more) Stored procedure ...
2
votes
1answer
55 views

Blackjack game with database - follow-up

This is a follow-up to my ex-posted Blackjack game that uses a MySQL database to store the accounts and user's money. I tried splitting display_info() a bit, I also ...
3
votes
1answer
70 views

Blackjack game with database

This is the latest version of my Blackjack game and I did a quite big update to it. Now you can make an account that is saved in the MySQL database and you can bet money that are also saved in the ...
4
votes
1answer
58 views

Registration and login script

This is a registration and login script I have made in Python 3. It uses a MySQL database. In the future I might use it with my Blackjack game and add a row called ...
1
vote
0answers
23 views

Determining daylight-saving time in Central European Time

The following constellation: Our applications passes date&time around (in the most horrible way possible). We want to simplify this. Instead of a culture-specific string like '31.12.2019', we're ...
1
vote
0answers
37 views

Writing SQL queries to retrieve data from given tables

Good day, I am a college student and lately we had an assignment where we were tasked to write SQL commands on various questions depending on the information that is needed to be displayed from 3 ...
3
votes
2answers
75 views

Download and save bulk URL concurrently

I am new to Go and wrote program to download and save bulk URLs concurrently. It is working correctly, but I would like to make it more efficient and follow best practices. ...
2
votes
0answers
42 views

Generic library for querying various kinds of databases

Since C# 8 and .Net Core 3 are going to be released sometime this year, I wanted to try and convert the library I made to make querying databases easier, implementing the already accepted features (...
2
votes
0answers
23 views

Insert data from one table to another (million+ rows)

I have a procedure that collects data from one table and inserts it into another table with the same columns, but after correlating with a few other tables. Since the existing table (from which data ...
3
votes
0answers
28 views

MySQL JSON diff procedure

I'm building a procedure which compares two JSON objects and return two JSON objects with differences between each (compared keys and values). But I have relatively superficial SQL knowledge, so I ...
0
votes
0answers
19 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
25 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? ...
0
votes
2answers
53 views

Improving/ Optimizing Performance Query in MySQL PHP

I have invoices, invoices_items, order, order_items. <...
1
vote
0answers
42 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? ...
2
votes
0answers
36 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 ...
1
vote
1answer
75 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 ...
0
votes
0answers
7 views

MySQL insert record to one table to another if postid is not exist

Is there any way to write this query in a better way than this if I want to insert postid from posts table to ...
1
vote
0answers
22 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
74 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
14 views

Window function in MySQL 8

I'm running the following query on my database: ...
0
votes
0answers
45 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 ...
2
votes
2answers
66 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
29 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
87 views

Modify a column in 2 tables based on trigger

This is SQL Server 2008r2. First, here are some tables and data for test: ...
2
votes
2answers
113 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
15 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
71 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
120 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
38 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
127 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
254 views

MySQL database schema for e-commerce website

I'm making an e-commerce site, using MySQL for storing data. ...
3
votes
1answer
31 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
114 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
58 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 ...
2
votes
1answer
68 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
41 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 ...