I'm trying to use a sub query on a select statement for a field value but I can't seem to figure out the correct syntax. I want to pull a list of company names and as a field for that query, I want to select all the employees for that company.
Any ideas on what I'm doing wrong? The error I get is
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS
T-SQL code:
SELECT
company_name,
company_type,
(SELECT
employee_firstname, employee_lastname
FROM
tblemployees
WHERE
tblemployees.company_id = tblCompanies.company_id) as employees
FROM
tblCompanies
Desired output:
Company Name | Company Type | Employees
----------------------------------------------------------
Test Co | Construction | Bob Smith, Jack Smith, etc