Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Convert Fetch XML to SQL Query

$
0
0

Hi all

Below is my Fetch XML

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="contact">
<attribute name="telephone1" />
<attribute name="contactid" />
<attribute name="emailaddress1" />
<attribute name="lastname" />
<attribute name="jobtitle" />
<attribute name="firstname" />
<attribute name="parentcustomerid" />
<order attribute="firstname" descending="false" />
<filter type="and">
<condition attribute="emailaddress1" operator="not-null" />
</filter>
<link-entity name="account" from="accountid" to="parentcustomerid" alias="bd">
<filter type="and">
<condition attribute="aw_segmentid" operator="in">
<value uiname="E" uitype="aw_segment">{12345678-1234-5678-1234-123456789123}</value>
<value uiname="S" uitype="aw_segment">{12345678-1234-5678-1234-123456789124}</value>
</condition>
</filter>
<link-entity name="opportunity" from="customerid" to="accountid" alias="be">
<filter type="and">
<condition attribute="aw_payment" operator="ne" uiname="V" uitype="aw_payment" value="{12345678-1234-5678-1234-123456789125}" />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>

and below is my converted SQL query

SELECT DISTINCT contact.telephone1
, contact.contactid
, contact.emailaddress1
, contact.lastname
, contact.jobtitle
, contact.firstname
, contact.ParentCustomerIdName
FROM contact
INNER JOIN account AS bd
ON contact.parentcustomerid = bd.accountid
INNER JOIN opportunity AS be
ON contact.accountid = be.customerid
WHERE
bd.aw_segmentid in ('{12345678-1234-5678-1234-123456789123}','{12345678-1234-5678-1234-123456789124}') AND Contact.EMailAddress1 is not null OR
be.aw_payment !='{12345678-1234-5678-1234-123456789125}'
ORDER BY contact.firstname

The results of both are not matching. There is some problem, I know. Please mention my mistake on this query.

Thank You


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>