Hotel__c ht=[select Guest Name__c, Room Type__c from Hotel__c where Hotel Name__c=R-0005];
System.debug('play'+ht);
here it gives error
Line: 1, Column: 10 Unexpected token 'ht'.
There are a few syntax errors with the SOQL query that are causing this error to occur.
It looks like you are trying to alias the field names; however, this feature is only available for aggregate queries. To resolve this issue you'll need to remove Guest
, Room
, and Hotel
from the query.
R-0005
must be wrapped in single quotes since it is not a SOQL keyword.
Hotel__c ht=[select Name__c, Type__c from Hotel__c where Name__c='R-0005'];
System.debug('play'+ht);
insert myList;
andupdate aRecord;
. What you have here is a SOQL query. Also, unsure if this would cause the error but you're missing the single quotes aroundR-0005
at the end of your query (string literals must be enclosed in single quotes).Guest_Name__c
,Room_Type__c
,Hotel_Name__c
? (Note the underscores that are not in your original post.) Be sure you are using the correct API Name of the fields and not the Field Label.