Q:

Unexpected Token Where

  for(AggregateResult hier:hierarchy) {
    fld1.add((String)hier.get(Field1));
    fld2.add((String)hier.get(Field2));
    fld3.add((String)hier.get(Field3));
           }

        string Soqlstr2='Select Name FROM' + val + ' WHERE ' + Field1 + ' IN :\'' + fld1 + '\' AND ' +
            Field2 + ' IN :\'' + fld2 + '\' AND ' +
            Field3 + ' IN :\'' + fld3 + '\' AND ' +'\'';

I am getting an error :

Unexpected Token Where . 

A:

Your query is missing a space after FROM. The resulting query would look like
SELECT Name FROMAccount WHERE ...

This is a very easy error to make, and is why I always recommend using String.format() to build Dynamic SOQL queries, as I mentioned on one of your previous questions.
You are also using Apex binding incorrectly. An Apex bind takes the form :VARIABLE, as in WHERE My_Field__c IN :collectionOfValues. Your query adds the literal string value of the variable after the binding colon, which will produce confusing errors at run time.
I strongly recommend that you take the time to read through the entirety of Salesforce's SOSL and SOQL Reference. Your questions indicate that you are working on a project involving a lot of complex querying. You need to establish a foundation in how these query languages work in order to do so effectively.

