The following query returns the expected recordset but all those subqueries look weird to me.
Is there a way of optimizing it? Thank You
<cfquery name="session.getJobs" datasource="#db#">
SELECT
j.*,
IIF([status] = 'completed','b','a') as statusorder,
j.duration*u.BasicFees as charges,
(select userLastName+' '+userFirstName+', '+userTitle from users where userId = j.providerId) as provName,
(select userCity from users where userId = j.providerId) as provCity,
(select userstateProv from users where userId = j.providerId) as provState,
(select Company from users where userId = j.providerId) as provLocation,
(select userAddress1 from users where userId = j.providerId) as provAddress,
(select userZipcode from users where userId = j.providerId) as provZip,
(select userPhone from users where userId = j.providerId) as provPhone
from JobsDB j, users u
WHERE j.clientID = #cookie.newClientId#
AND u.userId = #cookie.newClientId#
order by j.jobID asc
</cfquery>
Is there a way of optimizing it? Thank You
<cfquery name="session.getJobs" datasource="#db#">
SELECT
j.*,
IIF([status] = 'completed','b','a') as statusorder,
j.duration*u.BasicFees as charges,
(select userLastName+' '+userFirstName+', '+userTitle from users where userId = j.providerId) as provName,
(select userCity from users where userId = j.providerId) as provCity,
(select userstateProv from users where userId = j.providerId) as provState,
(select Company from users where userId = j.providerId) as provLocation,
(select userAddress1 from users where userId = j.providerId) as provAddress,
(select userZipcode from users where userId = j.providerId) as provZip,
(select userPhone from users where userId = j.providerId) as provPhone
from JobsDB j, users u
WHERE j.clientID = #cookie.newClientId#
AND u.userId = #cookie.newClientId#
order by j.jobID asc
</cfquery>