Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 26th, 2005, 06:40 AM
Authorized User
 
Join Date: Oct 2003
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
Default The correlation name is specified multiple tim

Hi,

I have a function that allows for multivalue parameters.

I have a sp that needs to have multiple where clauses but if i have more than one it returns the error in the subject line.
My function which I found on the internet:
CREATE FUNCTION dbo.UDF_CharCommaSeparatedListToTable
(
@CommaSeparatedList VARCHAR(8000)
)
RETURNS @ParsedTableValue TABLE (TableValue VARCHAR(1000))
AS
BEGIN
DECLARE @TableValue VARCHAR(1000)
DECLARE @Pos INT



SET @CommaSeparatedList = LTRIM(RTRIM(@CommaSeparatedList))+ ','
SET @Pos = CHARINDEX(',', @CommaSeparatedList, 1)

IF REPLACE(@CommaSeparatedList, ',', '') <> ''
BEGIN
WHILE @Pos > 0
BEGIN


SET @TableValue = LTRIM(RTRIM(LEFT(@CommaSeparatedList, @Pos - 1)))
IF @TableValue <> ''
BEGIN
INSERT INTO @ParsedTableValue (TableValue)
VALUES (RTRIM(@TableValue))
END
SET @CommaSeparatedList = RIGHT(@CommaSeparatedList,
LEN(@CommaSeparatedList) - @Pos)
SET @Pos = CHARINDEX(',', @CommaSeparatedList, 1)
END
END

RETURN
END


The query that returns the error:

SELECT dbo.UserTable.UserID, dbo.UserTable.FirstName, dbo.UserTable.FamilyName,dept
FROM dbo.UserTable

 INNER JOIN
 dbo.UDF_CharCommaSeparatedListToTable(@param)b ON

RTRIM(b.TableValue) = UserTable.UserID

inner join dbo.UDF_CharCommaSeparatedListToTable(@dept)b ON

RTRIM(b.TableValue) = UserTable.dept

I need to create something like this:

SELECT dbo.UserTable.UserID, dbo.UserTable.FirstName, dbo.UserTable.FamilyName,dept
FROM dbo.UserTable

where userid in(25,85) and
dept in (28)






Similar Threads
Thread Thread Starter Forum Replies Last Post
using checkbox in login form remember me next tim avnishraj23 ASP.NET 2.0 Basics 1 December 4th, 2007 08:36 PM
Importing Multiple files in Multiple tables Versi Suomi Access 6 June 1st, 2005 08:47 AM
Correlation sets jsfitter Biztalk 0 March 4th, 2005 12:03 PM
Multiple Joins in Multiple Table Search query pookster Access 4 September 23rd, 2004 03:04 PM
Error in Correlation Property Initialization vijay_rb Biztalk 1 August 17th, 2004 08:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.