Hacker News new | ask | show | jobs
by mulmen 2239 days ago

  SELECT Email
  FROM mailing_list
  ORDER BY JoinDate

  SQL Error: There is no field named JoinDate in the resulting FROM table.
Ok? What engine is this using? That's valid SQL in my universe.

In PostgreSQL 12:

  mulmen@shell> psql
  psql (12.1)
  Type "help" for help.

  mulmen=# CREATE TABLE foo ( bar INT, baz INT );
  CREATE TABLE
  mulmen=# INSERT INTO foo VALUES (1, 10), (2, 20);
  INSERT 0 2
  mulmen=# SELECT bar FROM foo ORDER BY baz;
   bar
  -----
     1
     2
  (2 rows)

  mulmen=#
2 comments

Thank you for the feedback. The SQL parsing is home made and I assumed fields in the order by clause is also a part of the SELECT. I collect a window of failed queries in memory (without knowing who sent what) to find cases like this and fix them.
Syntax is fine, it's complaining because you didn't include `JoinDate` column in your query.
This appears to be a syntax error. I get a different error if I add JoinDate to the SELECT clause without adding the other columns it wants.