I can’t understand why the same query for select and delete have different behavior. I need to delete all rows except 5 newest rows. I know my solution for this task is no good, but my question is …
Tag: mysql
Filtering out non-zero values unless the value is the only one within its group (SQL or R)
I have a data set of record numbers, with multiple values in a column for each record. I would like to produce a table where within each group it returns the minimum non-negative, non-NA value. But if …
PHP and Mysql, avoid multiple loop queries
I have a table myTable that looks like this: +——-+——-+——–+————+ | Id | Agent | Qualif | Date | +——-+——-+——–+————+ | 1 | A | Q1 | 2019-05-…
mysql – GROUP_CONCAT rows into a string
I have a following result set: req_id | p_id | ai_result | hash | sku 1 | 4 | Match | XAN | HOW 1 | 4 | Match | HXN | HOW 1 | 4 | Non Match | 123 | …
Counting How ID has Same Join Combination?
I has Join table, and result is like this IDA IDB QTY A 3 1 A 4 1 A 5 1 B 3 1 B 4 1 C 3 2 D 3 2 E 3 1 F 4 1 G 3 1 G 4 1 G 5 1 H 3 3 H 4 3 H …
Delete rows to keep only top values in a sql table
I am trying to have some product recommendations in my website. I have this table that i have generated but need to keep a limited amount of entries. The table consists of these columns (filling with …
Replace Database field based on 2 different Table Conditions
I need to update the table based on email matching condition and need to know SQL query that can solve this problem. I have 2 tables “old_data” and “new_data” Old_data contains around 60,000 records …
How to select only rows from a table one clumns value is more than b table count value in MySQL
Table A: id, name, school_code ——————- 1,David,10601 2,Jack,10602 3,John,10603 4,Hank,10602 5,Daisy,10601 6,Kelly,10602 7,May,10602 8,Mayme,10602 Table B: id, school_code,max_stu ——-…
How to fix, where condition with update not working
I am trying to update my table using where condition. I am not sure where I am going wrong. I am using peewee for SQL queries in python. I am trying to update two different tables having the same …
How to omit html tags in a mysql table attribute while doing a select
I have a table where each row consist of an attribute which consist of html data with like this. I need to omit the html tags and extract only the data inside the tags using sql query. Any idea on how to achieve this?. I tried out different regex but they didnt work. Answer There are 2 solutions based on