I am trying to do a dynamic SOQL for this i am adding a user id to it but while it is SOQL it is getting an error that : no viable alternative at character '\'. My SOQL look is like this SELECT name,Contact.CM_F__Profile_Completness__c, Contact.Account.CM_F__Profile_Completeness__c FROM User WHERE id = \'005900\'
My code for creating SOQL :
public String UserprofileSOQL {get; set;}
String userID = userinfo.getUserId();
UserprofileSOQL = 'SELECT name,Contact.'+homepgProfile[0].UserProfile_Field__c+', Contact.Account.'+homepgProfile[0].AccountProfile_Field__c+' FROM User WHERE id = \''+ userID +'\'';
userLst = Database.query(UserprofileSOQL);'
I am getting error while i query it. Please guide me to get a solution on this problem.