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.
1,457
questions
8
votes
2
answers
332
views
Local user registration
More javascript (nodejs) to go with the passport wrapper I just posted:
UserBook.js
...
4
votes
5
answers
20k
views
Convert Sql LIKE to Regex
I have a bit of code that converts a Sql Like expression to a regex expression for the purposes of a Linq to objects Like extension method. For some time I have ...
3
votes
2
answers
88
views
Optimized Query
I am having a structure of 3 tables
...
9
votes
3
answers
40k
views
SQL query where id=… or id=… or id=… etc [closed]
I haven't had much experience with postgresql (none) and I am wondering/hoping that there is a better way for me to do this query.
...
4
votes
3
answers
2k
views
Connecting to Oracle using ODP.NET
What can be improved in my code:
...
5
votes
3
answers
124
views
Remove duplication in SELECT statement
Say I have the following SQL:
SELECT
amount,
amount*.1,
(amount*1)+3,
((amount*1)+3)/2,
(((amount*1)+3)/2)+37
FROM table
Instead of ...
5
votes
2
answers
249
views
Exam score query for many types of exams
I have the following MySQL SELECT statement. It is working fine except that the code is too long. I have been looking throughout the Internet to figure out how I ...
4
votes
3
answers
10k
views
Speed up application and avoid SQL Timeouts
The code works just fine, but recently performace has taken a hit and it has SQL Timeouts far too often. I have it set up so I can run 50 different version of the application two for each different <...
2
votes
1
answer
962
views
Improve speed of LINQ query
How can I improve the speed of this LINQ query?
...
1
vote
2
answers
171
views
Stored procedure to run a credit-card debt query
This is a stored procedure that takes 5-30+ minutes to run depending on the parameter they select.
It also has a nasty side effect of clogging down our SQL Server.
...
2
votes
1
answer
188
views
Query too slow - Optimization
I am having an issue with the following query returning results a bit too slow and I suspect I am missing something basic. My initial guess is the 'CASE' statement is taking too long to process its ...
4
votes
3
answers
724
views
Injecting data into XML using a dll
This is a template for one of our data injection tokens.
When I first looked at the template, it was worse than it is now. I would like some input on this because I think that it can be cleaned up ...
2
votes
1
answer
1k
views
SQL database query wrapper
How can I write a better database query wrapper?
...
4
votes
2
answers
4k
views
E-commerce database design
I am new to database design but am fairly familiar with SQL and its syntax. I want to create a database for an e-commerce website that will sell a single product type such as a shirt. They could be ...
3
votes
2
answers
230
views
Computing the week for a certain date
I have the following SQL query that computes for every date the week it falls in (a week begins on Sunday and ends on Saturday):
...
6
votes
1
answer
994
views
Help optimizing this query with multiple where exists
In the application I'm building, the user is able to define 'types' where each 'type' has a set of 'attributes'.
The user is able to create instances of products by defining a value for each ...
2
votes
1
answer
77
views
Checking Synchronization issue in SQL?
I have the following SQL. I want to make that the SP should work under load. Means it should not have any synchronization issues.
...
1
vote
2
answers
91
views
Same records between two tables
I have the following tables:
...
1
vote
2
answers
2k
views
Maintaining a total balance of debit/credit sales transactions
The overall intent is to consolidate individual sales transactions to total debits/credits summing up the totals by year and month--retaining a running balance from start to end. This code uses ...
3
votes
2
answers
83
views
SQL Server 2012: How do I eliminate multiple statements in this code to a more efficient, single statement?
This code completes under a second, however its seems like I've taken the "Mr. Bean" way around getting there.
The goal is to get the average number of orders processed in a single day based on how ...
3
votes
1
answer
91
views
Oracle nested query
Essentially I'm attempting to select the top read (based on read_date), and check if it has a ...
4
votes
1
answer
9k
views
SQL query for monthly bills with amounts paid
The idea is to get a listing of monthly bills with amounts paid. The subquery does a total through a group by using bill_id and ...
1
vote
2
answers
322
views
3
votes
1
answer
528
views
DAL mapping efficiency
I am wondering if I can make these classes a bit more efficient.
Test Results
Single Run
Method 1: 5 Columns - Text Query - 81178 Records = 00:00:00.6390366
secs
Method 2: 5 Columns - Text Query - ...
5
votes
2
answers
2k
views
Improve query: find users who are neither friends nor fans of a user
Please take a look at this query and try to give me any other ideas that will give the exact same results more efficiently.
...
3
votes
3
answers
187
views
Code conversion from Access to T-SQL
I have an Access database that I'm converting to SQL Server 2008. One of the queries in the database uses the LAST function. The table has a AutoNumber ID so true order is simple.
...
3
votes
1
answer
289
views
Database schema for a Minecraft logging plugin
This is my attempt at creating a database schema for a Minecraft logging plugin. I'm by no means a SQL expert, so suggestions would be greatly appreciated.
...
3
votes
1
answer
83
views
Listing employees and their project tasks
My database (SQL Server 2008) looks like this:
People 1 -- * TaskPersons * -- 1 Tasks * -- 1 Project
The GROUP BY part of the query is quite long, all because ...
5
votes
3
answers
848
views
Lattitude document organizer
I'm not familiar with threads but I am not against them either. A bit of background the original program would have taken about 2 years to run. I had modified it and knocked down that time to around ...
2
votes
3
answers
3k
views
Choice of tables for a project to handle attendance
I'm working on my students attendance system project. I have a list of students along with their ID (jntuno) and I need to create a database in MySQL for storing ...
1
vote
1
answer
177
views
SQL with several joins
Is this query acceptable in terms of performance (I get the correct data) or can it be optimized?
...
1
vote
2
answers
91
views
Store procedure timing out sometimes
Can someone please find out why this store procedure is timing out?
...
2
votes
3
answers
279
views
Remove vulnerabilities from query on public website [closed]
I think that the following query is preventing against SQL injection, but what other measures do I need to take to ensure my queries are 100% safe from any malicious attacks?
...
3
votes
3
answers
2k
views
Simple CMS system
I'm working on a simple CMS with the intent of making it as secure as possible (a personal challenge) and the code as clean as possible. I think I've a long way to go so I would appreciate any input, ...
2
votes
1
answer
704
views
Correct use of my JOIN and arrays to fetch the data?
After learning a lot about programming, I've decided to write some code pertaining to scripting and use of different functions. I've come to a point where I'd like others to verify my code for ...
2
votes
1
answer
4k
views
PHP Pagination for 1,2,3... vs 1,2,3,4,5,etc
I am having an issue where I am doing a query and it is coming back with about 100 pages, I was hoping to have it come back with 1,2,3...30,31...99,100 instead of 1,2,3,4,5,6,7,8,etc. please see below ...
3
votes
1
answer
164
views
Querying a warehouse database
Consider the query given below:
...
1
vote
1
answer
51
views
Determining if someone has read and seen all the questions of a book
I am trying to evaluate if someone has read and seen all the questions of a book.
I am using PHP to average everything out after I get the data. I know MySQL can avg, but I can't seem to wrap my head ...
3
votes
1
answer
2k
views
Automating the install of PostgreSQL from Shell
When my Debian server deploys it can run a shell script so I wanted to make one to install postgreSQL, create a role, create two databases and then import a schema into one.
Can anyone please look ...
2
votes
1
answer
762
views
Reading Excel (93-97) sheet with more than 65536 rows using cfspreadsheet
I have a process that reads multiple sheets from an Excel file, then inserts the data into a database table. However, I am experiencing some memory issues when one of the sheets contains more than ...
1
vote
1
answer
87
views
First Schema for Location and Countries
This is my first MYSQL schema for caching location data (co-ordinates to place names) and referencing it with a country.
I was wondering what everyones feedback was on it, did I do a good job?
<...
0
votes
1
answer
4k
views
DB Query within foreach
I'd like a general opinion on my piece of code (which does exactly what I want it to do). I feel like I'm using bad practices, like a DB query within a foreach loop,...
5
votes
2
answers
3k
views
Selecting the number of working days minus weekend days and UK bank holidays
I am fairly new to coding TSQL script and am looking for some second view on my script.
The goal here is to to pull in some data and amongst that data to show a field with a counting the number of ...
1
vote
1
answer
107
views
Platform for creating data-oriented web apps
In my web development company, we have many designers who have the following development knowledge:
Client-side web languages (HTML, CSS, JavaScript)
Basic database design (how to create tables, ...
4
votes
1
answer
65
views
Time spent by product in process represented by clockin and clock out
This is the code I wrote to find out the time spent by product in process represented by clockin and clock out. Time stamps X and Y (for example, 7/23/2013 7:00 AM and 7/23/2013 8:00 AM) reflect the ...
2
votes
1
answer
150
views
Running a master query and a query of queries
The following is code I'm running to FIRST, SECOND, THIRD and so on until ...
2
votes
1
answer
15k
views
Multiple input fields from PHP table
To summarize from a previous question, the user selected a starting date, an ending date, and a region. From these choices, an array of weeks and regions are created, and users enter values ("points") ...
6
votes
1
answer
186
views
Optimizing a query with many joins
I have a query which selects a show from anime_series, then selects corresponding information from other tables (such as studio, which is stored as a SMALLINT ...
7
votes
1
answer
629
views
Logfile parser for Team Fortress Classic video game
I'm currently working on a logfile parser for a pretty old videogame called Team Fortress Classic, which can be compared to Counter-Strike 1.6 and is available on Valve's Steam platform.
I started ...
5
votes
1
answer
160
views
Optimize postgres function
This function code works very slowly. How can I speed it up?
...