I'm trying to sort a table of dates into ascending or descending order, but I can't get it to do either. The query isn't giving a syntax error so I don't think it's that.
Server version: 5.7.28-0ubuntu0.18.04.4 (Ubuntu)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
mysql> select * from elections order by 'last_election' ASC;
+--------+-----------------+---------------+
| row_id | jurisdiction_id | last_election |
+--------+-----------------+---------------+
| 1 | 3 | 2018-11-24 |
| 2 | 2 | 2019-03-23 |
| 4 | 5 | 2018-03-17 |
| 5 | 4 | 2017-11-25 |
| 6 | 1 | 2016-10-15 |
| 7 | 6 | 2017-03-11 |
| 8 | 7 | 2018-03-03 |
| 9 | 8 | 2016-08-27 |
| 11 | 9 | 2019-05-18 |
+--------+-----------------+---------------+
9 rows in set (0.00 sec)
Previous / other similar questions all say, "Your field type is text or varchar, duh!" but the field type is definitely date:
+----------------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+---------+------+-----+---------+----------------+
| row_id | int(11) | NO | PRI | NULL | auto_increment |
| jurisdiction_id | int(11) | NO | UNI | NULL | |
| last_election | date | YES | | NULL | |
+----------------------+---------+------+-----+---------+----------------+
How do I query the table so that last_election is in order?