The error might be shown because of an incorrect trigger…
Category: MySQL
mySQL ORDER BY null before DESC
If you try to sort numbers by ABS -> DESC and intend to get the null or other specific values first use this order by
ORDER BY column IS NULL DESC, ABS(column) DESC
//for NULL values
ORDER BY column='' DESC, ABS_(column) DESC
//for anything else
Source: https://stackoverflow.com/questions/9307613/mysql-order-by-null-first-and-desc-after
mySQL converting lat/lon to spatial
INSERT INTO myTable (coordinates)
SELECT GeomFromText(CONCAT('POINT(',ot.latitude, ' ', ot.longitude,')'))
FROM otherTable ot;
or
UPDATE myTable
SET coordinates = GeomFromText(CONCAT('POINT(',latitude, ' ', longitude,')'));
MySQL determine max number of character in a field
SELECT MAX((column1)) maxCol1,
MAX(CHAR_LENGTH(column2)) maxCol2
FROM tableName
MySQL find first, last row
SELECT
this,
query,
SUBSTRING_INDEX(GROUP_CONCAT(CAST(rocks AS CHAR) ORDER BY _date), ',', 1 ) as top,
SUBSTRING_INDEX(GROUP_CONCAT(CAST(rocks AS CHAR) ORDER BY _date DESC), ',', 1 ) as bottom
FROM database