We present a sample of 8498 quasars with both Sloan Digital Sky Survey (SDSS) ugriz optical and United Kingdom Infrared Telescope (UKIRT) Infrared Deep Sky Survey (UKIDSS) YJHK near-infrared (near-IR) photometric data. With this sample, we obtain the median colour-z relations based on 7400 quasars with magnitude uncertainties less than 0.1mag in all bands. By analysing the quasar colours, we propose an empirical criterion in the Y-K versus g-z colour-colour diagram to separate stars and quasars with redshift z<4, and two other criteria for selecting high-redshift quasars. Using the SDSS-UKIDSS colour-z relations, we estimate the photometric redshifts of 8498 SDSS-UKIDSS quasars, and find that 85.0 per cent of them are consistent with the spectroscopic redshifts within |{Delta}z|<0.2, which leads to a significant increase of the photometric redshift accuracy from that based on the SDSS colour-z relations only. As two tests, we compare our colour-selection criterion with a small UKIDSS/EDR quasar/star sample and a sample of 4671 variable sources in the SDSS Stripe 82 region with both SDSS and UKIDSS data. We find that they can be clearly divided into two classes (quasars and stars) by our criterion in the Y-K versus g-z plot.