0

I am trying to come up with the node.js code to get the output of this query:

const viewAllEmployees = () => {
let sql = 'SELECT e.id, e.first_name, e.Last_name, r.title, d.name as "Department", salary, CONCAT (m.first_name," ", m.last_name) AS "Manager" 
FROM employee e '  + connection.escape('INNER JOIN employee m 
ON e.manager_id = m.id 
LEFT JOIN role r 
ON e.role_id = r.id 
LEFT JOIN department d 
on r.department_id = d.id');
    connection.query(sql, (err, res) => {
    if (err) throw err;
    console.table(res);
    // console.log(res);
    //connection.end();
  });

The problem is that when I use it without the connection.escape(), I get the output, but with single quotes like this:

enter image description here

How can I (1) get rid of the (index) column, and (2) get rid of the single quotes? Getting rid of the single quotes is really the priority.

Thanks!

1 Answer 1

1

Index column and quotes are added by console.table function itself.

You can check it running console.table with any static data like here: https://developer.mozilla.org/en-US/docs/Web/API/Console/table#collections_of_primitive_types

To print it in a way you want it, implement printing function on your own.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much, Eugene. Your answer is what I was looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.