I'm getting a application going and I'm fairly new to sqlite. I'm converting the following query from SQL Server to SQLite but I'm getting the error "Error while executing SQL query on database 'SampleDataBase': ambiguous column name: nClientWorkerID". Below is the script I'm writing.
Sql Server Script :
select distinct tblWorkers.nClientWorkerID, nWorkerFirstname, nWorkerLastname, nWorkerSuffix, nTitle, nStatusShort, nStatusColor from tblWorkers
left join tblTitles on tbltitles.iTitleID = tblworkers.iTitleID
left join tblEDLWorkers on tblEDLWorkers.nClientWorkerID = tblWorkers.nClientWorkerID
left join tblEventDateLocations EDL on EDL.iEDLID = tblEDLWorkers.iEDLID
left join tblEventDates on tblEventDates.iEventDateID = EDL.iEventDateID
left join
(select nClientWorkerID, nStatusColor, nStatusShort from tblTimeLog
join tblTimeStatuses tblStatus on tblStatus.iTimeStatusID = tblTimeLog.iNewStatusID
where tblTimeLog.iTimeLogID in
(select max(iTimeLogID)
from tblTimelog group by nClientWorkerID)
group by nClientWorkerID, nStatusColor, nStatusShort) TimeLog
on Timelog.nClientWorkerID = tblworkers.nClientWorkerID
where tblEventDates.dEventDate = Convert(date, getdate())
and
((EDL.nClientLocationID = (select nvalue from tblElectionSettings where nKey = 'CurrentLocation')
and
tblEventDates.iEventID = (select cast(nvalue as integer) from tblElectionSettings where nKey = 'CurrentEvent'))
or
tblWorkers.nClientWorkerID in (select nClientWorkerID from tblTimeLog where dCreationDate = GETDATE()
and nClientLocationID = (select nvalue from tblElectionSettings where nKey = 'CurrentLocation'))
)
SQLite Query :
select distinct tblWorkers.nClientWorkerID, nWorkerFirstname, nWorkerLastname, nWorkerSuffix, nTitle, nStatusShort, nStatusColor from tblWorkers
left join tblworkers on tbltitles.iTitleID = tblworkers.iTitleID
left join tblWorkers on tblEDLWorkers.nClientWorkerID = tblWorkers.nClientWorkerID
left join tblEDLWorkers on tblEventDateLocations.iEDLID = tblEDLWorkers.iEDLID
left join tblEventDateLocations on tblEventDates.iEventDateID = tblEventDateLocations.iEventDateID
left join
(select nClientWorkerID, nStatusColor, nStatusShort from tblTimeLog
join tblTimeStatuses on tblTimeStatuses.iTimeStatusID = tblTimeLog.iNewStatusID
where tblTimeLog.iTimeLogID in
(select max(iTimeLogID)
from tblTimelog group by nClientWorkerID)
group by nClientWorkerID, nStatusColor, nStatusShort) TimeLog
on TimeLog.nClientWorkerID = tblworkers.nClientWorkerID
where tblEventDates.dEventDate = (select date('now'))
and
((tblEventDateLocations.nClientLocationID = (select nvalue from tblElectionSettings where nKey = 'CurrentLocation')
and
tblEventDates.iEventID = (select cast(nvalue as integer) from tblElectionSettings where nKey = 'CurrentEvent'))
or
tblWorkers.nClientWorkerID in (select nClientWorkerID from tblTimeLog where dCreationDate = (select datetime('now'))
and nClientLocationID = (select nvalue from tblElectionSettings where nKey = 'CurrentLocation'))
)
The area I'm concerned with is :
left join (select nClientWorkerID, nStatusColor, nStatusShort from tblTimeLog
Aucun commentaire:
Enregistrer un commentaire