Reputation: 1070
I'm trying to write a statement like this:
SELECT
TBL_CS_LINKS.LINK_ID,
TBL_CS_LINKS.LINK_NAME,
TBL_CS_LINKS.LINK_URL,
( SELECT COUNT(*)
FROM TBL_CS_TEMP_CLICK
WHERE TBL_CS_TEMP_CLICK.LINK_ID = 1)
FROM TBL_CS_LINKS
join right TBL_CS_TEMP_CLICK
on TBL_CS_LINKS.LINK_ID = TBL_CS_TEMP_CLICK.LINK_ID
WHERE
(CHARINDEX('s', TBL_CS_LINKS.LINK_URL) > 0) OR
(CHARINDEX('s', TBL_CS_LINKS.LINK_NAME) > 0)
order by TBL_CS_LINKS.LINK_NAME
and it gives me an error :
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'right'.
What could be the problem ?
Thanks!
Upvotes: 0
Views: 1394
Reputation:
you got the keywords in the wrong order.
It's
right join
left join
or
right outer join
left outer join
Upvotes: 4
Reputation: 13496
You have used the right keyword incorrectly. Please check below for the proper use of it
SELECT TBL_CS_LINKS.LINK_ID,
TBL_CS_LINKS.LINK_NAME,
TBL_CS_LINKS.LINK_URL,
(SELECT COUNT(*) FROM TBL_CS_TEMP_CLICK WHERE TBL_CS_TEMP_CLICK.LINK_ID = 1)
FROM TBL_CS_LINKS
right join TBL_CS_TEMP_CLICK
on TBL_CS_LINKS.LINK_ID = TBL_CS_TEMP_CLICK.LINK_ID
WHERE (CHARINDEX('s', TBL_CS_LINKS.LINK_URL) > 0) OR
(CHARINDEX('s', TBL_CS_LINKS.LINK_NAME) > 0)
order by TBL_CS_LINKS.LINK_NAME
Upvotes: 2