mysql get last row
SELECT fields FROM table ORDER BY id DESC LIMIT 1;
mysql get last row
SELECT fields FROM table ORDER BY id DESC LIMIT 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;
mysql last year
SELECT * FROM my_table
WHERE YEAR(my_date) = YEAR(DATE_SUB(CURDATE(), INTERVAL 1 YEAR));
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%")
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us