how to select all feilds in soql code example
Example 1: how to select all fieldsin a soql query
Map<String, Schema.SObjectField> fieldMap = Opportunity.sObjectType.getDescribe().fields.getMap();
Set<String> fieldNames = fieldMap.keySet();
List<Opportunity> opps = Database.query('select ' + string.join(fieldNames, ',') + ' from Opportunity');
Example 2: how to select all fieldsin a soql query
Id rId = 'SomeValidSFDCId';
DescribeSObjectResult describeResult = rId.getSObjectType().getDescribe();
Map<String, Schema.SObjectField> fieldMap = describeResult.fields.getMap();
Set<String> fieldNames = fieldMap.keySet();
String soqlQuery = ' SELECT ' + string.join (fieldName, ',') + ' FROM ' + describeResult.getName() + ' Where Id =: rId';
List<sObject> record = Database.query(soqlQuery);