[SalesForce] How to Retrieve related record value using SOQL

I'm using Case object and it has a look up of Service_Technician__c. Now i want to get the Service technician name which is related to a Case. How can i retrieve a service technician name using SOQL?
I tried like below:

sforce.connection.query("SELECT Id, CaseNumber, Reason, Status, (SELECT Id, Name FROM Service_Technician__c WHERE id= '"+account.Assigned_To__c+"'),Service_Date__c FROM Case WHERE Status='New'",{
    onSuccess : layoutResults,
    onFailure : queryFailed,
    source : {
        output : document.getElementById("output"),
        startTime : new Date().getTime()
        }
});

Assigned_To__c is a look up name in Case Object

Best Answer

What you are doing right now (i.e. using a sub-query) would work for querying child-relations. But in this case you're following a lookup and not querying a child-relation at all.

In the case of querying a lookup field, you can simply use the __r version of the fieldname to query fields from that relation. So in this case use Assigned_To__r.Name to query the Name of the Technician.

SELECT Id, Assigned_To__r.Name FROM Case WHERE Status='New'

See the documentation for more information.