update items as a
inner join (
	select ffzg_inventura.barcode,items.datelastseen,max(ffzg_inventura.date_scanned) as date_scanned
	from ffzg_inventura
	join items on items.barcode = ffzg_inventura.barcode
	group by ffzg_inventura.barcode
	having datelastseen < max(date_scanned)
) as b
on a.barcode = b.barcode
set a.datelastseen = b.date_scanned ;

