liviutrt:INSERT INTO table2 (ws_id, content_id)
SELECT @term_id, tag_ref_id FROM table1 WHERE tag_type_id = 0 AND word_lemma = @term
GROUP BY tag_ref_id
Innainte de a vorbi despre optimizari, hai sa vorbim despre ce anume vrei sa obtii cu acest INSERT ... SELECT. Mai exact, la ce anume foloseste clauza GROUP BY?
http://rusanu.com