The better option is to store the car price data like this:Code Year Price
354 2008 23000
354 2008 25000
354 2008 28000
467 2008 35000
467 2009 39000
467 2010 43000
Then your query is a simple JOIN:SELECT C.make, P.*
FROM CarInfo C
INNER JOIN CarPrices P ON C.LineCode=P.Code AND C.Year=P.Year