Get the number of rows returned by a query in MySQL
Is there an easy way to get the number of rows returned by a query as well as the rows themselves. For example, in a stored procedure, I need to return rows from a query and, if no rows are…
Is there an easy way to get the number of rows returned by a query as well as the rows themselves. For example, in a stored procedure, I need to return rows from a query and, if no rows are…
I am doing this HackerRank SQL question and cannot understand why this OFFSET does not work.This is for MySQL syntax: SELECT ROUND(LAT_N, 4) FROM STATION ORDER BY LAT_N LIMIT 1 OFFSET (SELECT FLOOR(COUNT(*) / 2) FROM STATION); But if I…
I have a weird issue that I'm hoping is just something stupid I'm overlooking (and will gladly eat crow on). I have a Spring Boot project that makes use of Spring Data JDBC. It also uses Testcontainer's MySQL container for…
I have a VIEW that looks like this: | email | list | sent_last_30_days | -------------------------------------- | email1 | list1 | 1 | | email2 | list1 | 0 | | email1 | list2 | 1 | | email3 |…
/$sql = "SELECT * FROM tb_cad WHERE name like '$src_names%' ORDER BY id ASC"; $query = mysqli_query($conn, $sql); Id | name ------------ 1 James 2 Claus 7 John 10 Maria 21 Sonia 22 Evelin How do I get the result…
Given: MySQL 8 and INSERT INTO ... ON DUPLICATE KEY UPDATE query, which is applied to existing records in the table. It is necessary that if the existing value of the field is not NULL, and NULL is passed in…
We have a lot of data with a lot of events with a lot of dates in a MySQL db. Generating lists of e.g. events per year, or students per year, is fairly simple. Now, we've decided to change everything…
I have table with over 35 million email records. I need to get all of the records between a date range and also exist at least 3 times in the table. 1 email may have more than one property but…
I unexpectedly executed the following query in MySQL and got a strange result: SELECT 'a' 'b' 'c' FROM dual; The result shows 'a' as the column name and 'abc' as the value. I am puzzled by this behavior. What is…
I have following 2 tables: Sales and Menu. SALES TABLE customer_id product_id A 1 A 2 A 2 A 3 A 3 A 3 B 1 B 1 B 3 B 3 B 2 B 2 C 3 C 3…