SELECT * FROM photos f, users u WHERE f.uid = u.userid and f.red = $red and f.yellow = 0 and f.green = 0 and f.magenta = 0 and f.blue = 0 and f.multicolor = 0or f.uid = u.userid and f.red = 0 and f.yellow = $yellow and f.green = 0 and f.magenta = 0 and f.blue = 0 and f.multicolor = 0or f.uid = u.userid and f.red = 0 and f.yellow = 0 and f.green = $green and f.magenta = 0 and f.blue = 0 and f.multicolor = 0or f.red = 0 and f.yellow = 0 and f.green = 0 and f.magenta = $magenta and f.blue = 0 and f.multicolor = 0or f.red = 0 and f.yellow = 0 and f.green = 0 and f.magenta = 0 and f.blue = $blue and f.multicolor = 0or f.red = 0 and f.yellow = 0 and f.green = 0 and f.magenta = 0 and f.blue = 0 and f.multicolor = $multicolour