Skip to main content

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 vote
3 answers
1k views

Saving Multiple Lists to Database - C# Forms

I am trying to store multiple lists to a database but I'm struggling on finding a better way of doing it, as the way I am doing it now, seems to be incorrect. On my form, I have 6 different legs. Each ...
Jimmy293288's user avatar
0 votes
2 answers
185 views

Version 2: Display visitor's number on your web page (changed code after getting answer for first version)

Version 2: Display visitor's number on your web page (changed code after getting answer for first version). The first version is here: Display visitor's number on your web page The "visitors&...
user avatar
0 votes
1 answer
281 views

Display visitor's number on your web page

Display visitor's number on your web page. The "visitors" table has only one column (visitor_count) and only one row. The column's initial value is 0. I know goto should not be used but then ...
user avatar
3 votes
2 answers
112 views

Change query strings with a Bash script

The following script changes start and end dates of several queries saved as files in the folder /app/queries. It is used by executing the script and passing two ...
Moritz Loritz's user avatar
1 vote
1 answer
40 views

PostgreSQL query which return metrics joining different tables

I have a query that can be seen on this fiddle and I'm relatively new to PSQL, having a few months of experience. DB Fiddle As mentioned in the comment I should put the query here and the code is ...
Jakub's user avatar
  • 271
2 votes
1 answer
645 views

SQL query to find expenditures of employees who have exceeded their limit

I've 2 tables emp and expenditure. Emp: ID, NAME Expenditure: ID, EMP_ID, AMOUNT Each emp has a limit of 100 that he/she can ...
reiley's user avatar
  • 137
1 vote
1 answer
74 views

Updating multiple database tables when products are shipped back by customer

So, in this example I have to make these changes in my tables: Select Product Data => SKU, QTY Insert into shipping_back table Update in shipping_back to current date Update in customers to ...
kviktor1230's user avatar
2 votes
0 answers
22 views

Plpgsql function that redacts substrings wrapped with double pipes `||`

I'm using Postgres 14 and I've written a function (for use with Hasura GraphQL Computed Fields) that transforms a TEXT field, replacing all instances of spoiler-annotated text (e.g. ...
Alex Meuer's user avatar
3 votes
2 answers
152 views

RawSqlQuery minimizing risk of field name confusion

Is there a way to make the following code more maintainable? ...
Kirsten's user avatar
  • 433
-1 votes
1 answer
57 views

Which one is faster and preferable when doing aggregate function to the data in sql? CASE WHEN or WHERE? [closed]

I have following simple sql code to select the number of rows that meet a specific criteria: SELECT COUNT(CASE WHEN /*condition*/ THEN 1 END) FROM table_name; ...
James's user avatar
  • 121
1 vote
1 answer
78 views

Search controller logic to search through models and manufacturers

I have the following Laravel controller that searches through two models - Manufacturer and SearchTerm (which contains models of manufacturers, synonyms of models as well as common misspellings) using ...
Hashim Aziz's user avatar
1 vote
1 answer
132 views

Creating SQL query for relative timeframes and multiple tables

What I want to achieve: I have several tables of the following schema: +------+-------+ | date | val | +------+-------+ | DATE | INT64 | +------+-------+ I want ...
Moritz Loritz's user avatar
2 votes
2 answers
175 views

Is this a good way to process an order? (SQL+PHP)

I'm making a simple webshop, it's not the full code, there are more security procedures. I'm just want to know your opinions. Thank you. These SQL tables I have: (I have more column in this table this ...
kviktor1230's user avatar
2 votes
1 answer
76 views

Calculate time interval excluding breaks

I have a solution for a question I asked on SO: I am trying to create a database where I also need to find the time difference inside a record. However, timediff() ...
Memo Haldan's user avatar
1 vote
1 answer
132 views

Creating database and two tables linked by foreign key

These commands do what I want, but I'm trying to find out the best approach for this. My main areas of concern are: error handling and disposal of resources. In regards to error handling, I'm catching ...
Pablo Aguirre de Souza's user avatar

15 30 50 per page
1
3 4
5
6 7
98