You have to use variable binding :
return [select ItemSKU__c from Product__c where Description__c LIKE :skey];
Also var isn't a data type in Salesforce. If you want to return the Product__c
record, then you have to return the 'Product__c' sObject type on your method, like:
// actually the query returns a list of Product__c
public List<Product__c> doSomething(){
return [SELECT ItemSKU__c from Product__c where Description__c LIKE :skey];
}
Seems that skuController()
is the constructor of your Apex controller and the constructors shouldn't return anything. If that's the case, then on the constructor you can make initializing as below:
public class skuController {
public List<Product__c> productList { get; set; }
// controller
public skuController() {
productList = [SELECT ItemSKU__c from Product__c where Description__c LIKE :skey];
}
}
A better approach would be to use lazy loading if you are on Apex Visualforce controller:
public List<Product__c> getProducts() {
get {
if (productList == null) {
productList = [SELECT ItemSKU__c from Product__c where Description__c LIKE :skey];
}
return productList;
}
set;
}
And e.g. the VF page would be:
<apex:page controller="skuController">
<apex:form >
<apex:pageBlock>
<apex:pageblockTable value="{!products}" var="p">
<apex:column value="{!p.ItemSKU__c}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>