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.

Filter by
Sorted by
Tagged with
0
votes
0answers
20 views

How to manage multiple bookings in same order in SQL? [closed]

I am working with system that user can book services. I am developing using PHP and MySQL. Now Currently all things are working fine. But I need to manage Multiple Bookings in Same OrderId What Issue ...
3
votes
1answer
52 views

Any ideas how do I prettify this SQL query?

This question is abut coding style. I'd like to see how would you improve this code look considering readability as well. Feel free to upvote others solutions you find good. #1 Initial version: ...
5
votes
1answer
1k views

Multi-query PHP Parser for SQL files

I have an external project, which needs to run an SQL file containing multiple SQL queries (a bit like mysqldump, if you like, but is user-created, with any kind of SQL statement/definition). PHP ...
3
votes
1answer
159 views

ToDoApp - adding users, managing tasks, getting tasks

I've implemented a console ToDo application. I would like to hear some opinions about it, what should I change etc. About project: It is intended to manage everyday tasks. Application contains: ...
3
votes
0answers
27 views

Login function with python and SQLite

I'm a new programmer who is currently working on a personal project. It is supposed to be a login program which stores user data in a SQLite database. I was wondering if anyone could look at my code ...
3
votes
2answers
53 views

Database Design for representing category relationships

So I am new to Databases.Recently I was asked this question in an interview where they expected me to come with a schema for storing and retrieving categories for an E-commerce website in an RDBMS. ...
2
votes
0answers
23 views

Using R to Dynamically Query Database Using SQL Template

Purpose of Code The purpose of the main function (get_player_penalties()) is to: Generate simple SQL statements from user input and a template Query a database ...
2
votes
1answer
57 views

Login system in PHP using AJAX

I am beginning the cycle of creating my role based access control into my framework. I now want to log the user into my application and my _user table looks like this: ...
3
votes
1answer
77 views

Does PDO::quote helps me to protect me against sql injection?

I have to process raw sql user input with Laravel. I've backed them up as follows: ...
2
votes
1answer
20 views

VB.net SQL match against Excel data to datagridview

I am importing an Excel sheet where the first column will contain product numbers. I match those numbers to my SQL database and display the product number and description of the matching products to a ...
4
votes
1answer
97 views

Generic solution to Hibernate's CriteriaQuery

I've created a little class which helps me to generalize many query cases. I have a DbService and couple methods in it. Can you please take a look at it and share some criticism? The usage of that ...
2
votes
1answer
40 views

Selecting changes from a temporal table

I'm using Temporal Tables on postgresql (https://github.com/arkhipov/temporal_tables) and C# with dapper. I'm storing an entity together with its changes. Here's an example entity, with an Id and two ...
2
votes
1answer
25 views

Database playground

This is my very first interaction with databases. The goal is to setup a safe playground on an Arch box to create tables and make queries. I want to learn the basics without risking ...
3
votes
1answer
102 views

How secure is my login and signup code

I am creating a social network and I've been told a few times a lot of things are outdated and prone to SQL injections so I am going over everything with a very fine comb and checking what's good and ...
2
votes
1answer
32 views

stat the word count for a given stackexchange user

Sometimes I would like use word count to describe someone's contribution, so, I wrote a query to stat the word count for a given stackexchange user, based on SEDE. click to run it online ...
3
votes
0answers
46 views

SQL database implementation - statement execution

This is another class from my implementation of SQL in C#. It handles the execution of SQL statements, with the core method looking like this: ...
3
votes
1answer
270 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 ...
2
votes
1answer
79 views

How to make this query better (e.g. avoid repeating subquery in a query)?

Stack Exchange provides access to query their MS SQL databases. They have a table Posts where each post is either a question or an answer (see the schema on right ...
2
votes
1answer
42 views

Query to retrieve available stock

I have a query that outputs a list of products with some fields from other tables. That query works fine. Now, I'm attempting to retrieve the available stock for each product in that list. I'm not ...
1
vote
1answer
39 views

SQL String to get data from DB2

I decided to split the SQL Part away from This Question. Before we get started I need to let you know a critical piece of information: Due to permissions within an offsite database I am NOT allowed to ...
2
votes
1answer
44 views

Fully buffered stream with atomic commit

This is a class from an implementation of SQL in C# I am writing. It fully buffers all reads and writes, and also logs changes to a log file so that updates are atomic ( all or nothing ). It ...
3
votes
2answers
46 views

Fetching all nodes of a directed graph by an id of any node

Task: Rowset of all reachable(in any direction) nodes from any node in a graph. In other words I need to extract all nodes of a particular graph from a table in the database where graph specified by ...
2
votes
0answers
85 views

Spark Scala: SQL rlike vs Custom UDF

I've a scenario where 10K+ regular expressions are stored in a table along with various other columns and this needs to be joined against an incoming dataset. Initially I was using "spark sql rlike" ...
5
votes
1answer
217 views

SQL QueryBuilder

I've made a simple querybuilder for my job, but I'm kind of insecure about starting to use it because I'm afraid of errors happening when I start using it. I've done some tests with ...
1
vote
1answer
56 views

Reduce database touches for one to many data pull

I have the following function which works properly and grabs all of the rows from a specific table, then loops through each row to add data related to it as a subarray. ...
1
vote
0answers
13 views

there are a better solutions to set FIELDS as data at ADODB query from xls file (exported from SAP)

My excel program import from another workbook, exported from SAP, some columns to update my dashboard. To do this I use ADODB, the code run right and fast (26K rows and 32 columns on 00:00:26:1226). ...
1
vote
1answer
18 views

SQL Negation: Find X when X does not do Y

I'm learning The essence of SQL by Rozenshtein indirectly from the SQL Cookbook which has a section on it with modern SQL ...
1
vote
1answer
46 views

Functional Python Script to write a large amount of CSVs to database

I just finished up this script that crawls hundreds of local git repos for csv files and then stores them into a database. I've tried to follow a "functional" paradigm for this script but am kind of ...
1
vote
1answer
39 views

filter SE posts with specific keywords

I am trying to find all the SE answers which contain "on context" in a single sentence, in the meanwhile the "on" is not a part of common collocations in any form, such as "depending on context", "...
3
votes
1answer
111 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, ...
1
vote
0answers
28 views

Slow updates with updating rows in database with preparedStatement [closed]

I have been shifting all of my SQL queries to prepared statements in the past few weeks and all of the INSERT statements run extremely fast, however, UPDATE is taking an inordinate amount of time. At ...
4
votes
0answers
57 views

Postgres Shopping Database using Python

So I have just started to work with SQL and I have tested my script and is working very well when it comes to my database. The database is used for shopping. What I mean by that is that I scrape a ...
5
votes
4answers
421 views

Reduce the code in a WHERE clause without using dynamic SQL

How can I write the following T-SQL query part in a shorter way without using dynamic SQL? ...
1
vote
1answer
26 views

Count distinct records in a JOINed SQL query

I have two tables with a 1-many relationship, Device and TestResult. My application has a filter builder front-end that allows a user to retrieve TestResults based on whatever filters they specify. ...
2
votes
2answers
55 views

Receive data from SQL and CSV and send it to MySQL database using Python

Details: I have a code, which does the following: Get data from CSV and insert it into MySQL table Get data from SQL Server and insert it into MySQL table Run this code every 240 seconds - to ...
1
vote
0answers
24 views

querying users from table if user.id is found in another table

I am using flask with sqlAlchemy to connect with a postgresql database with two tables Users table (id, name) ...
-1
votes
1answer
23 views

SQL Group qry by codeProduct and Last(description) [closed]

For the ADMIN: I wrote this tread on S.O. questions/61183026, but I think that is more correct to post this tread here, if you think no, please scuse me and delete this message. Hi, I've one xls ...
3
votes
1answer
36 views

Modelling user preference system with categories

I am modelling a user preference system with the following requirements a user can have attributes (foods they eat) a user can have dynamic categories of preferences users which have all their ...
1
vote
0answers
26 views

Code for tracking changes and deletions to tables

I have written a SQL server stored procedure to generate "log" tables which store the old values of rows when a table is updated, and also record when rows are deleted ( and by who ). It's quite ...
1
vote
0answers
13 views

Moving hierarchy with the most revisions with more performance (SQL)

I have hierarchical table for my features with a parent-child relation. There was an unique constraint missing, why I have branches in the data, where multiple children relate to one parent. To add ...
1
vote
1answer
31 views

Calling a function within stored procedure to derive a value

I am trying to write a sql storeprocedure that basically returns a derived value from an outcome of a function call. The derived field returns the difference in days and if the difference is less ...
1
vote
2answers
75 views

Faster/Better Processing for SQL While Loop

I have a list of about 55k Accounts that I am cleaning up. 95% of them are from US/Canada which is what I'm most concerned with. I am going through record by record and will perform various checks ...
1
vote
1answer
38 views

capturing counts of open items between dates

DB version is: Oracle 12c. Restricted to the use of inline PL/SQL. The end goal here is to get a count of open items by day, inclusive of created date, exclusive of the end date. The data ...
4
votes
3answers
8k views

Database design with information of employees, their jobs, salaries and projects

I am doing a database design I want to create a database with information of employees, their jobs, salaries and projects. I want to keep information of the cost of a project (real value of project ...
4
votes
1answer
30 views

Select latest phase of objects not marked “remove”

I have the following table in a PostgreSQL DB (simplified for the question), where I want to select only the rows marked with *: ...
2
votes
0answers
30 views

Python class for helping template SQL queries when working with psycopg2

While working on a project to do some spatial data processing in PostgreSQL, I found it cumbersome to use the psycopg2.sql objects to safely compose queries. I ...
1
vote
2answers
35 views

SQL to match string value against multiple columns

I have a table called tblStudent having data as I want to retrieve records having single value compared against multiple columns. For example - find all students having Grade 'C' in any of the ...
1
vote
1answer
39 views

Get average post score of TOP 10 tags on StackOverflow using Stack Exchange Data Explorer

I want to use the Stack exchange data explorer in order to display some basic information about the top tags. The query should print the number of questions and answers, the average number of answers ...
0
votes
1answer
38 views

PHP - Importing columns from uploaded CSV file to SQL database (Laravel 5.7) [closed]

The goal is to upload the columns from the csv into the SQL Pro database. I am able to select the column names that have been uploaded from the csv file, the columns from the csv file are then ...
2
votes
0answers
20 views

Entity - Model (EAV) system with delta updates

I am trying to create my first eav system that can handle updates as well. The user can create models with list and objects inside and with references other models. the user can then create instances ...

1
2 3 4 5
28