select DISTINCTROW p.CatalogId,p.cname from products p, prodcategories cc, categories c where cc.intCatalogId=p.CatalogId and cc.intcategoryid=c.categoryid AND p.cname like 'F%' AND p.hide = 0 and (p.customermatch is null or p.customermatch = '') and (p.loggedin = false or p.loggedin is null) and (c.customermatch is null or c.customermatch = '') and (c.loggedin = false or c.loggedin is null) AND (higherCatalogId is null) order by p.cname