sql server - SQL - replace returned data with other data -
i retrieving data using sql syntax below:
select top 5 eventid, eventtime, devicename, comment, tenant, tenantname, individual, inetdb.dbo.individuals.firstname, inetdb.dbo.individuals.lastname, inetdb.dbo.indivimages.userimage taclogdata.dbo.event left join inetdb.dbo.tenants on taclogdata.dbo.event.tenant = inetdb.dbo.tenants.tenantid left join inetdb.dbo.individuals on taclogdata.dbo.event.individual = inetdb.dbo.individuals.individ , taclogdata.dbo.event.tenant = inetdb.dbo.individuals.tenantndx left join inetdb.dbo.indivimages on inetdb.dbo.individuals.individ = inetdb.dbo.indivimages.indivndx , inetdb.dbo.individuals.tenantndx = inetdb.dbo.indivimages.tenantndx (taclogdata.dbo.event.eventtime > dateadd(hh, -3, getdate())and taclogdata.dbo.event.eventtime < getdate()) , (taclogdata.dbo.event.comment='reader entry' or taclogdata.dbo.event.comment='reader exit') , (taclogdata.dbo.event.devicename = 'l9 1/4/1' or taclogdata.dbo.event.devicename='l1 2/1/1-2 maind' or taclogdata.dbo.event.devicename='l1 2/1/3-4 maind' or taclogdata.dbo.event.devicename='l1 2/6/1-2 stair' or taclogdata.dbo.event.devicename='l1 2/2/1-2 fdt1') order taclogdata.dbo.event.eventtime desc
this code works fine, i'm trying simplify results.
i'm trying simplify query returns, replacing devicename value e.g. l1 2/1/3-4 maind main door when results shown (not replace actual data in database)
how may achieve please ?
in advance,
j
try use replace function
select top 5 eventid, eventtime, replace(devicename,'l1 2/1/3-4 maind','l1 2/1/3-4 main door') devicename, comment, tenant, tenantname, individual, inetdb.dbo.individuals.firstname, inetdb.dbo.individuals.lastname, inetdb.dbo.indivimages.userimage taclogdata.dbo.event left join inetdb.dbo.tenants on taclogdata.dbo.event.tenant = inetdb.dbo.tenants.tenantid left join inetdb.dbo.individuals on taclogdata.dbo.event.individual = inetdb.dbo.individuals.individ , taclogdata.dbo.event.tenant = inetdb.dbo.individuals.tenantndx left join inetdb.dbo.indivimages on inetdb.dbo.individuals.individ = inetdb.dbo.indivimages.indivndx , inetdb.dbo.individuals.tenantndx = inetdb.dbo.indivimages.tenantndx (taclogdata.dbo.event.eventtime > dateadd(hh, -3, getdate())and taclogdata.dbo.event.eventtime < getdate()) , (taclogdata.dbo.event.comment='reader entry' or taclogdata.dbo.event.comment='reader exit') , (taclogdata.dbo.event.devicename = 'l9 1/4/1' or taclogdata.dbo.event.devicename='l1 2/1/1-2 maind' or taclogdata.dbo.event.devicename='l1 2/1/3-4 maind' or taclogdata.dbo.event.devicename='l1 2/6/1-2 stair' or taclogdata.dbo.event.devicename='l1 2/2/1-2 fdt1') order taclogdata.dbo.event.eventtime desc
Comments
Post a Comment