Search From Database

Hi,
I have one array for example [1,2,3,4]
and
I want to check the array mathches in database

for example if this array mathches exactly
[1,2,3,4] == [1,2,3,4]
then storing it in one varibale
then find the array matches for [1,2,3] (remove last element)
then we will get some results and store it in one variable

The prblem here i am facing is how to remove last element of an array
i.e. like [1,2,3] and how to check the array matches in table