SELECT distinct categoryID, category FROM #variables.tableprefix#categories WHERE projectID = AND categoryID = AND type = ORDER BY category INSERT INTO #variables.tableprefix#categories (projectID,categoryID,type,category) VALUES (, '#newID#', , )