Sorry just read my post… what I meant to say is that the EmployerName would be stored in another table and the EmployerId would be the reference for this…
Basically trying to determine what table I should look up, either the employer or agency… does that make sense?
SELECT
ID
, employerid
, agencyid
FROM [tablename]
WHERE
( employerid > 0
AND EXISTS IN (SELECT employerid FROM employername WHERE LIKE ‘% %’))
OR
( agencyid > 0
AND agencyname LIKE ‘% %’)
I have a table with a row that can store Employer Id and Agency Id for storing a list of talent that can be either employer talent or agency talent. I need to be able to display a list of them and be able to search by either employername or agencyname too.
So depending on whether the row is showing a employer id or agency id I need to search the relevant joined table.
SELECT 'employer' AS result_type
, Employername AS name
FROM TalentTable
INNER
JOIN Employer
ON Employer.id = TalentTable.EmployerID
AND Employer.Employername LIKE '% %'
UNION ALL
SELECT 'agency'
, Agencyname
FROM TalentTable
INNER
JOIN Agency
ON Agency.ID = TalentTable.AgencyID
AND Agency.Agencyname LIKE '% %'
i still don’t understand why you’re searching for spaces…