Reputation: 14204
I'm not a SQL Server expert. I am trying to execute a query. The query relies on a function to split a CSV and doing a join on a table. Its a pretty basic query that looks like the following:
SELECT
*
FROM
[Order]
WHERE
dbo.ConvertIDListToTable('1,2,3,4', ',') l INNER JOIN Order o ON l.item=o.ID
When I execute the query, I get the following error:
An expression of non-boolean type specified in a context where a condition is expected, near 'l'.
What am I doing wrong? This has to be something syntactical. I keep staring at it, but everythign looks correct to me. Thank you.
Upvotes: 0
Views: 288
Reputation: 35106
I believe this query structure is from mysql
In SQL Server you would write it like this:
SELECT
*
FROM
[Order] o
Inner join dbo.ConvertIDListToTable('1,2,3,4', ',') l
ON l.item=o.ID
Upvotes: 0
Reputation: 1605
You cannot use a JOIN in a WHERE clause. It is indeed a syntax problem.
Look at SQL Server SELECT syntax : http://msdn.microsoft.com/en-us/library/ms189499.aspx
You should JOIN before the WHERE clause. If you want more help for your query please clarify what you want it to do.
Upvotes: 0
Reputation: 32690
Syntactically, your INNER JOIN
s should come before your WHERE
statement, and in addition, you don't need the WHERE
statement here.
Not knowing the exact code of ConvertIDListToTable
is a hindrance, but assuming it returns a table, I think you need:
SELECT *
FROM dbo.ConvertIDListToTable('1,2,3,4', ',') l
INNER JOIN Order o ON l.item=o.ID
Upvotes: 1