Tuesday, March 27, 2012

Filter and Joint

SELECT DISTINCT BannerGroups.BannerGroupCode, BannerGroups.BannerGroupName,
BannerGroups.BannerGroupContactName, BannerGroups.BannerGroupContactEmail
FROM BannerGroups INNER JOIN Customers ON BannerGroups.BannerGroupCode =
Customers.BannerGroupCode WHERE(Customers.CustomerInactive = 0) AND
(Customers.RepCode = {0})
the the query i need to do replication.
so how can i achieve the distinct function, coz i found we do not allow to
insert after select command.
please help
thanks
nick
Um... I take it you mean a Filter and a JOIN.
If by chance you do mean JOINT, this is perhaps not the most appropriate
newsgroup for you. However, I believe this query is from .Net - due to the
curly braces around the 0.
If you are using this as a filter in a replication publication you should
use the in clause instead of the equality clause.
So it would look like this
SELECT <published_columns> FROM <<TABLE>> WHERE
BannerGroups.BannerGroupCode in (SELECT
BannerGroups.BannerGroupCode FROM BannerGroups INNER JOIN
Customers ON BannerGroups.BannerGroupCode =
Customers.BannerGroupCode WHERE(Customers.CustomerInactive =
0) AND (Customers.RepCode = 0))
However, it is hard to tell from what you post exactly what you are trying
to accomplish.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
"Nick" <Nick@.discussions.microsoft.com> wrote in message
news:A920E9DE-1603-43DB-A26A-1B07614BB876@.microsoft.com...
> SELECT DISTINCT BannerGroups.BannerGroupCode,
BannerGroups.BannerGroupName,
> BannerGroups.BannerGroupContactName, BannerGroups.BannerGroupContactEmail
> FROM BannerGroups INNER JOIN Customers ON BannerGroups.BannerGroupCode =
> Customers.BannerGroupCode WHERE(Customers.CustomerInactive = 0) AND
> (Customers.RepCode = {0})
> the the query i need to do replication.
> so how can i achieve the distinct function, coz i found we do not allow to
> insert after select command.
> please help
> thanks
> nick
|||Thanks for your words
what's my problem with that query is , it can select 10 items with
bannerGroupCode =1 and other 6 itmes with bannerGroupCode=2 when i run that
query without distinct, but what i want is only select one items with
bannerGroupCode 1 and 2 each, that's why i put DISTINCT in from of
bannerGroupCode. it works in qery analyze.
now i want to do replication for this query. i tried query you post. but
seems doesn't work as well.
Cheers
nick
"Hilary Cotter" wrote:

> Um... I take it you mean a Filter and a JOIN.
> If by chance you do mean JOINT, this is perhaps not the most appropriate
> newsgroup for you. However, I believe this query is from .Net - due to the
> curly braces around the 0.
> If you are using this as a filter in a replication publication you should
> use the in clause instead of the equality clause.
> So it would look like this
> SELECT <published_columns> FROM <<TABLE>> WHERE
> BannerGroups.BannerGroupCode in (SELECT
> BannerGroups.BannerGroupCode FROM BannerGroups INNER JOIN
> Customers ON BannerGroups.BannerGroupCode =
> Customers.BannerGroupCode WHERE(Customers.CustomerInactive =
> 0) AND (Customers.RepCode = 0))
> However, it is hard to tell from what you post exactly what you are trying
> to accomplish.
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> "Nick" <Nick@.discussions.microsoft.com> wrote in message
> news:A920E9DE-1603-43DB-A26A-1B07614BB876@.microsoft.com...
> BannerGroups.BannerGroupName,
>
>

No comments:

Post a Comment