From the above @JennyB answer, here is the code below.
trigger caseTrigger on Case(before update)
{
set<Id> newSet = new set<Id>();
set<Id> oldSet = new set<Id>();
for(Case cs:Trigger.New)
{
newSet.add(cs.WebID__c);
}
for(Case cs:Trigger.Old)
{
oldSet.add(cs.WebID__c);
}
map<Id, WebID__c> allWebIdMap = new map<Id, WebID__c>(
[select Id, Status__c from WebID__c where Id IN: newSet
or Id IN:oldSet]);
map<Id, WebID__c> newWebIDMap = new map<Id, WebID__c>();
map<Id, WebID__c> oldWebIDMap = new map<Id, WebID__c>();
for(Id WebIDId : allWebIDMap.keySet())
{
WebID__c currentWebID = allWebIDMap.get(WebIDId);
if(newSet.contains(WebIDId))
{
newWebIDMap.put(WebIDId, currentWebID);
}
if(oldSet.contains(WebIDId))
{
oldWebIDMap.put(WebIDId, currentWebID);
}
}
for(Case c:Trigger.New)
{
String oldStatus = oldWebIDMap.get(Trigger.oldMap.get(c.Id).WebID__c).Status__c;
String newStatus = newWebIDMap.get(c.WebID__c).Status__c;
system.debug('---------oldStatus----------'+oldStatus);
system.debug('---------newStatus----------'+newStatus);
// perform required operation here
}
}