+ Start a Discussion

malformed query in sforce explorer

hello ,
 i am using sforce explorer . i have to do union of the results of two tables i.e. account and lead .
I have fired query i.e. select name from account union select company from lead
I want to union both results in one query , but it is giving me the error "malformed query "
Can anyone tell me whatsthe problem with this ??
and also "order by " is also not working in sforce explorer ..
Plz reply
Gareth DaviesGareth Davies
Sforce Object Query Language (SOQL)

Use the Sforce Object Query Language (SOQL) to construct simple but powerful query strings for the queryString parameter in the query call. 
Similar to the SELECT command in SQL, SOQL allows you to specify the source object (such as Account), a list of fields to retrieve, and conditions for selecting rows in the source object. This topic includes:

    * SOQL Syntax
          o conditionExpression Syntax
          o fieldExpression Syntax
    * Logical Operators
    * Changing the Batch Size in Queries
    * Querying Multi-Select Picklists
    * Filtering on Boolean Fields

:: Note

SOQL does not support all advanced features of the SQL SELECT command. 
For example, you cannot use SOQL to:
  • perform join operations, use wildcards in field lists,
  • use calculation expressions,
  • or specify an ORDER BY clause to sort rows in the result set.


Ref the API Version 7 Manual

Looks like you're trying to use standard SQL not the restricted SOQL set of commands.


You can't do joins or aggregates or order by in SOQL.  Please reference the documentation for SOQL limitations.