I have 2 layers of polygons in QGIS which are layer1 and layer2.
they both have column id.
The goal is to select items in layer1 that not appear in layer2 using unique field id.
For example:
layer 1 has id: 1, 2, 3, 4, 5
layer 2 has id: 1, 2, 3, 4
by using expressions like
id not in layer2
How can I write the expression to have item 5 in layer 1 selected?

array_agg("id")should give a list of all id's in the current layer. To check if the current feature's id is in the list of id's in another layer it would be something like:array_contains( aggregate('layer2','array',"id"), "id"). I haven't tested this expression so it may have errors. – csk Jan 09 '20 at 17:15