Two complete samples of objects in the range 17 < B < 18.5 are selected on the basis of optical variability and ultraviolet excess. Multicolour photometry, objective prism and slit spectra are used to ascertain the composition of the two samples. The sample of variables is found to be composed almost entirely of quasars. The sample of UVX objects appears to contain about 50 per cent white dwarfs or blue subdwarfs, and 50 per cent quasars. About 30 per cent of the quasars are included in the sample of variables and most of the remainder show significant variability.