I’ve seen similar questions but not quite hitting it on the head. I want to insert a value into a column, where a value in the column is equal to a certain value – ie 1. So, INSERT INTO table (…
Tag: mysql
mysql – running sums for multiple categories with group by clause
I have this table: CREATE TABLE tbl_sample ( ID SERIAL PRIMARY KEY ,sale decimal(10,2) ,pc varchar(45) ,trans_date date ); INSERT INTO tbl_sample VALUES (1,100, ‘p1′,’2019-08-27’ ),(2,150, ‘p2’,…
Creat procedure in mysql
I was learning sql from w3schools.Here is given simple mysql procedure but somehow I couldn’t to write down this procedure I’m new in sql please could you provide me with feedback. DELIMITER // …
Mysql Employee break time history with time difference
I have employee biometric log data with inoutmode flag. I am trying to get detail break time list and with time difference. inoutmode 4 as break-out and 5 as break-in. INSERT INTO `tbl_downloadentry`…
MySQL : Insert Statement to add a record in TABLE_1
A single insert statement to add a new record in TABLE_1 for which : TABLE_1_ID value to be inserted as total count of records in TABLE_1 + 1. COLUMN_NAME will have value as “ABC”. TABLE_2_ID value …
Slow Moving Stock Items Query
I am trying to return a list of slow-moving stock items. Whenever there is a sale, the items are written to the saleItems table. I want to get those items from inventoryMaster table that are not …
get the count of unread messages
I have this requirement with our DB like shown below I want to get the 3 columns requestType, CategoryGroup, and count of readStatus column The result will show all the requestType along with …
SQL GROUP_CONCAT query assistance
I am having some problems figuring out the best use of GROUP_CONCAT. In the query below I am trying to select multiple images from JAM_Plot_Images and set them against single records. So get record …
PDO changes query
I want to have result of my query as it was before I replaced db connection using PDO. How can I get the query as i t was before I implemented PDO? This is my query: $query = “SELECT `…
How do I find the 2nd most recent order of a customer
I have the customers first order date and last order date by doing MIN and MAX on the created_at field (grouping by email), but I also need to get the customers 2nd most recent order date (the order date right before the last orderdate ) Answer Use window function ROW_NUMBER() (available in MySQL 8.0): This will get you the earlierst