Monday, February 20, 2012

Multipart Identifier??

I am getting an error: Multi-part identifier Ad.IPCode could not be bound.
What does that mean? This is my query:
SELECT Ad.ObjectID, ObjectTypeCode
FROM dbo.ClassifiedAd Ad, dbo.Objects O
JOIN dbo.CommunityProfile CP
ON Ad.IPCode = CP.IPCode AND
CP.StatusCode = 1
WHERE Ad.StatusCode = 1 AND
Ad.Published = 1 AND
Ad.ObjectID = O.ObjectID AND
CONTAINS((SUBJECT, HTMLBody), 'for sale' )Be more axplicit in your FROM clause:
SELECT Ad.ObjectID
,ObjectTypeCode
FROM dbo.ClassifiedAd Ad
inner join dbo.Objects O
on Ad.ObjectID = O.ObjectID
JOIN dbo.CommunityProfile CP
ON Ad.IPCode = CP.IPCode
AND CP.StatusCode = 1
WHERE Ad.StatusCode = 1
AND Ad.Published = 1
AND CONTAINS((SUBJECT, HTMLBody), 'for sale' )
Oh, yes - is there an IPCode yolumn in the dbo.ClassifiedAd table?
If so, then the optimizer might have processed the explicit join (... JOIN
ON ...) before the implicit one (FROM dbo.ClassifiedAd Ad, dbo.Objects O ...
WHERE ...)
ML
http://milambda.blogspot.com/|||Why are you mixing join types (old-style vs. ANSI)? Why do you not use the
alias prefixes on all of your columns? I'll try to re-write this so the
parser understands it, but I have no idea what your table structure looks
like, so I can't fix all the prefixes.
SELECT
Ad.ObjectID,
O.ObjectTypeCode
FROM
dbo.ClassifiedAd Ad
INNER JOIN
dbo.Objects O
ON
Ad.ObjectID = O.ObjectID
INNER JOIN
dbo.CommunityProfile CP
ON
Ad.IPCode = CP.IPCode
AND CP.StatusCode = 1
WHERE
Ad.StatusCode = 1
AND Ad.Published = 1
AND CONTAINS((SUBJECT, HTMLBody), 'for sale' );

>I am getting an error: Multi-part identifier Ad.IPCode could not be bound.
> What does that mean? This is my query:
> SELECT Ad.ObjectID, ObjectTypeCode
> FROM dbo.ClassifiedAd Ad, dbo.Objects O
> JOIN dbo.CommunityProfile CP
> ON Ad.IPCode = CP.IPCode AND
> CP.StatusCode = 1
> WHERE Ad.StatusCode = 1 AND
> Ad.Published = 1 AND
> Ad.ObjectID = O.ObjectID AND
> CONTAINS((SUBJECT, HTMLBody), 'for sale' )|||try this.
Select * from tbl1
where @.searchparam like '%' + email_col + '%'
hope this helps.|||sorry... wrong thread :)
--
"Omnibuzz" wrote:

> try this.
> Select * from tbl1
> where @.searchparam like '%' + email_col + '%'
> hope this helps.
>|||Thanks Aaron. Now I get this: Syntax error near 'sale' in the full-text
search condition 'for sale'.
"Aaron Bertrand [SQL Server MVP]" wrote:

> Why are you mixing join types (old-style vs. ANSI)? Why do you not use th
e
> alias prefixes on all of your columns? I'll try to re-write this so the
> parser understands it, but I have no idea what your table structure looks
> like, so I can't fix all the prefixes.
> SELECT
> Ad.ObjectID,
> O.ObjectTypeCode
> FROM
> dbo.ClassifiedAd Ad
> INNER JOIN
> dbo.Objects O
> ON
> Ad.ObjectID = O.ObjectID
> INNER JOIN
> dbo.CommunityProfile CP
> ON
> Ad.IPCode = CP.IPCode
> AND CP.StatusCode = 1
> WHERE
> Ad.StatusCode = 1
> AND Ad.Published = 1
> AND CONTAINS((SUBJECT, HTMLBody), 'for sale' );
>
>
>
>
>
>|||> Thanks Aaron. Now I get this: Syntax error near 'sale' in the full-text
> search condition 'for sale'.
I am not overly familiar with fulltext search, so assumed that syntax was
correct. I would probably write it as a LIKE or PATINDEX condition (again,
still knowing nothing about your table schema, specifically what datatypes
are Subject and HTMLBody, and what table are they in).

No comments:

Post a Comment