避免重复行并在多次插入后插入id

First question is I have a sql query like below.. And how to get ids of test, test1 and test2?

INSERT IGNORE INTO tags (tag_name) VALUES ('test'),('test1'),('test2')

There is a table to match tag_id and ann_id(announcements).The structure of the table is

tag_id(int 6)
ann_id(int 6)

I want to avoid duplicate lines. Is there anything that i can do with mysql for solve this problem? Or I must create a select query and count?