This code illustrates how to do what, I think, that you want using arrays. If not, you will have to better explain the requirements of the program.
const char *names[] = {"NAME1", "NAME2", "NAME3", "NAME4"};
long ids[] = {8867111, 8921255, 8226572, 822854};
const int numIds = 4;
long testId = 8226572;
char thisName[16]; // will match the ID
long thisId;
void setup()
{
Serial.begin(115200);
for (int n = 0; n < numIds; n++)
{
if (ids[n] == testId)
{
strcpy(thisName, names[n]);
thisId = ids[n];
}
}
Serial.print("CODE = ");
Serial.print(thisId);
Serial.print(" NAME = ");
Serial.println(thisName);
}
void loop()
{
}
And the output using the test ID.
CODE = 8226572 NAME = NAME3