Reply
Regular Contributor
sridevi
Posts: 15
0

How to write a select query using two tables and compare two id's?

[ Edited ]

Hi All,

 

I am working on salesforce to java integration through webservices

 

How to write a select query using two tables like QuoteLineItem and PricebookEntry and compare id's  and get the product2id . this query how to write ?

 

i write a query like this 

 

QueryResult q = binding.query("select id,(select id,product2id from PricebookEntry)from QuoteLineItem");

 

i am getting errors

 

AxisFault
faultCode: {urn:fault.enterprise.soap.sforce.com}INVALID_TYPE
faultSubcode:
faultString: INVALID_TYPE:
id,(select id,product2id from PricebookEntry)from QuoteLineItem
^
ERROR at Row:1:Column:38
Didn't understand relationship 'PricebookEntry' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
faultActor:
faultNode:
faultDetail:
{urn:fault.enterprise.soap.sforce.com}InvalidSObjectFault:<ns1:exceptionCode>INVALID_TYPE</ns1:exceptionCode><ns1:exceptionMessage>
id,(select id,product2id from PricebookEntry)from QuoteLineItem
^

 

plz help..

 

 

Contributor
varun.sforce
Posts: 6
0

Re: How to write a select query using two tables and compare two id's?

Use as following....

 

select id,PricebookEntry.product2id from QuoteLineItem

 

Regular Contributor
sridevi
Posts: 15
0

Re: How to write a select query using two tables and compare two id's?

Hi Varun,

 

ok ,I need to compare both object id's PricebookEntry object id and QuoteLineItem object PricebookEntryId

 

like this  PricebookEntry.id = QuoteLineItem.PricebookEntryId  if both id's same get the product2Id

 

How to write single sql query?

 

plz need help...

Regular Contributor
Trinay
Posts: 36
0

Re: How to write a select query using two tables and compare two id's?

[ Edited ]

Hi Devi,

 

 To accomplish this u need to write the query using INNERJOIN. Try the following: 

 

SELECT PricebookEntry.id,PricebookEntry.product2id FROM QuoteLineItem INNER JOIN PricebookEntry ON QuoteLineItem.Id=PricebookEntry.Id

 

I hope this will helpful for you.

Thanks,
www.trinay.com
570-575-0475