So I’m making a php website that sometimes requires a big data input from an admin-type user. This would not be frequent and only would happen to update or add certain data to the DB. During this upload time which probably will take a minute or two, I cannot have other Users try to pull the data and and…
Tag: mysql
Combining 2 Tables in SQL and add a new column to a Table
I have 2 Tables. CustomerDetails table has columns ID, UUID, Name, Age. FavoriteCustomers table has columns ID, UUID CustomerDetails Table will have a lot of entries say 10000 rows. while FavoriteCustomers Table has very few entries. In CustomerDetails Table, ID and UUID form the combined unique ID. Now I wan…
How to exclude weekends and holidays dates and find an expected date in MySQL?
I am working on a task where I have 2 tables. i.e, tickets and holidays. Now I also have the number of days to complete the tickets. Now I need to find the expected date by excluding holidays(specified in the holidays table) and weekends. Now I can able to find a date using ticket created date and days to com…
How do I make ORDER BY work when creating a procedure in MySQL?
I’m trying to create a procedure that inserts the data of a new lecturer, then shows the last 3 lecturers added. This is what my table (lecturers) looks like: And this is my attempt to create the procedure: Then I call the procedure with this data for example: However, ORDER BY does not seem to be doing…
How to select from table A only where a relationship between the table A row and a specific row in B exists? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question lets say I have two MySQL tables, table A and table B. Each table has a pri…
Whats wrong with my query, should i use WHERE?
So, what am i doing wrong? This query: Will give me this error: Failed to run query: SQLSTATE[HY000]: General error: 1111 Invalid use of group function This query: Will give me this error: Failed to run query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check …
SQL: Convert bigint type to formatted date
I believe this is a simple question, but I’ve been searched around and got no satisfactory answer. Basically I have a Bigint object in MYSQL, I want to convert it to date format like 20201004, for example: I’ve tried But neither allow formatting, I hope to get the easiest and fastest conversion. A…
Fill every minute in an interval of timestamps with a static record in a MySQL table
I have a time series in MySQL and need to write a cycle as described by the pseudocode below: how do I write this, optimally, in MySQL? Answer You can use a recursive CTE: Here is a db<>fiddle.
MySQL – select distinct values from a column where values are separated by comma
To get the list of distinct values from table1 and column1 is as easy as doing this: However, I inherited (unfortunately) a database where column1 contains values separated by a comma I need to get the list of distinct values from column1, so it looks like this: Any ideas? Answer A generic method uses a recur…
Syntax error in SQL when inserting data via nodejs
I have a simple nodejs code in pipedream that sends the body email to mySQL Database. i have checked the connection to database and its working. Here is my code const mysql = require(‘mysql2/promise’);…