function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sandeep reddy 37sandeep reddy 37 

how can we do dynamical soql no of fields

this is my program how to fetch all the myphone,myname fields please tell me
   public class dynamicallsoql {
    public string myname{set;get;}
    public stringmy phone {set;get;}
    public sobject obj {set;get;}
    public list<sobject> sobj{set;get;}
    public dynamicallsoql(){
        database.query('select'myname,myphone 'from' obj);
    }

}
}
Piyush Kumar 58Piyush Kumar 58
Hello Sandeep,

Try to query like this :-
database.query('select'+myname,myphone+ 'from'+obj);

Thanks.
Nayana KNayana K
Database.query('SELECT '+ myname+ ','+ myphone +' FROM  '+ obj);

 
sandeep reddy 37sandeep reddy 37
nayana i did but no error i apex and vf also but not not giving output just give me example
Nayana KNayana K
Can you please post whole code along with vf and controller