How to Create a filter List from two lists?

I have two lists that is created by adding items from two text boxes
Text Box 1: Name
Text Box 2: Class

the result is like this
list 1: ahmed,peter,mark,mostafa,john
list 2: A,B,B,A,B

and you can add more …

I need to great a list that auto shows only the class according to the data entered
list 3: A,B

I need that the elements of this list is auto added not manually entered
as when a new entries like C

it shows List 3: A,B,C

I hope my request is clear ,
a Category List that is auto Filled

thanks in advance every one

use the sqlite database, create a table with 2 columns name and class and add your records
then use a select statement like this SELECT DISTINCT class FROM myTable


how to do it using blocks as I never used SQLite Database before?

you might want to search for sqlite tutorials

if you do not like to use the sqlite component (well, I recommend it, because it would reduce your blocks drastically), you also can take a look at @Abraham_Getzler’s method here