Subquery execution

17 views
Skip to first unread message

Tremaine Buchanan

unread,
Jun 9, 2017, 9:52:03 PM6/9/17
to node-mysql
Hi, I'm trying to conduct a subquery however I'm getting the following error:

{
  "code": "ER_BAD_FIELD_ERROR",
  "errno": 1054,
  "sqlState": "42S22",
  "index": 0
}

This is the query: 'SELECT id, first_name, last_name, docs = (SELECT COUNT(id) FROM documents WHERE employee_id = employees.id ) FROM employees'.

The column 'docs' doesn't exist in the table employees. I would like to compute this field based on the count of documents from the documents table.
Reply all
Reply to author
Forward
0 new messages