Answers for "mysql last"

SQL
7

mysql get last row

SELECT fields FROM table ORDER BY id DESC LIMIT 1;
Posted by: Guest on March-04-2020
1

mysql last date

-- Max date for each model:
SELECT model, max(date) FROM models GROUP BY model;
-- All models matching the max date of the entire table:
SELECT model, date FROM models WHERE date IN (SELECT max(date) FROM models);
-- Same with model details:
SELECT d.model, d.date, d.color, d.etc FROM models d
WHERE d.date IN (SELECT max(d2.date) FROM models d2 WHERE d2.model=d.model);
-- Faster with MySQL 8.0+
SELECT model, date, color, etc FROM (SELECT model, date, color, etc, 
  max(date) OVER (PARTITION BY model) max_date FROM models) predoc 
WHERE date=max_date;
Posted by: Guest on June-13-2021
0

how to fetch data from database without last column

SELECT lastName,firstName FROM Customer
       WHERE lastName LIKE "B%"
         AND city = "Indianapolis"
         AND (phone LIKE "%8%" OR fax LIKE "%8%")
Posted by: Guest on November-09-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language