Please help me to convert this Sql statment to <Fetch> XML query

SELECT *
FROM ContactBase Cont INNER JOIN
AccountBase Acct ON Cont.AccountId =
Acct.AccountId AND Cont.ContactId IN
(SELECT primarycontactid
FROM Accountbase
WHERE Acct.Name = 'Accountname')


Srini....

Re: <Fetch> by Jeffry

Jeffry
Mon Jan 16 07:41:49 CST 2006

As far as I know (please correct me if I'm wrong) you cannot retrieve fields
from multiple entities using the QueryExpressions and Fetch methods.

You can join entities, but only to apply conditions/filters. E.g. get
appointments where customer.lastname = 'kennedy'. You then join the
appointment with account and filter on account.lastname.

HTH,

--
Jeffry van de Vuurst
CWR Mobility
www.cwrmobility.com
--
"srini" <sreenumay15@gmail.com> wrote in message
news:1137190010.155510.294530@o13g2000cwo.googlegroups.com...
> Please help me to convert this Sql statment to <Fetch> XML query
>
> SELECT *
> FROM ContactBase Cont INNER JOIN
> AccountBase Acct ON Cont.AccountId =
> Acct.AccountId AND Cont.ContactId IN
> (SELECT primarycontactid
> FROM Accountbase
> WHERE Acct.Name = 'Accountname')
>
>
> Srini....
>



Re: <Fetch> by srini

srini
Tue Jan 17 10:28:55 CST 2006

Jeffry-

I have solved my problem. for your reference I am attaching that fetch
xml query

<fetch><entity name='Account'>"
<link-entity name='Contact' to='primarycontactid' from='contactid'
link-type='outer'>"
<all-attributes/>
</link-entity>
<link-entity name='Account' to='accountid' alias ='account'
from='accountid' link-type='inner'>
<attribute name= 'accountnumber'/>
<attribute name='name'/>
</link-entity>
<filter type='and'>
<condition attribute='accountid' operator='in'>
<value>Account Guid value</value>
</condition>
</filter></entity></fetch>

if you have a time try the above and let me know. It is working for me.
this is the fetch xml query I wanted.

Srini.......


Re: <Fetch> by Jeffry

Jeffry
Tue Jan 17 13:39:41 CST 2006

Ah great, so it is possible using Fetch!

I'll try it out and let you know if it works for me, but I'm sure it will if
you got it to work :)

Thanks,

--
Jeffry van de Vuurst
CWR Mobility
www.cwrmobility.com
--
"srini" <sreenumay15@gmail.com> wrote in message
news:1137515335.114097.227880@f14g2000cwb.googlegroups.com...
> Jeffry-
>
> I have solved my problem. for your reference I am attaching that fetch
> xml query
>
> <fetch><entity name='Account'>"
> <link-entity name='Contact' to='primarycontactid' from='contactid'
> link-type='outer'>"
> <all-attributes/>
> </link-entity>
> <link-entity name='Account' to='accountid' alias ='account'
> from='accountid' link-type='inner'>
> <attribute name= 'accountnumber'/>
> <attribute name='name'/>
> </link-entity>
> <filter type='and'>
> <condition attribute='accountid' operator='in'>
> <value>Account Guid value</value>
> </condition>
> </filter></entity></fetch>
>
> if you have a time try the above and let me know. It is working for me.
> this is the fetch xml query I wanted.
>
> Srini.......
>