Is there something wrong with my "IN" statement?

 

SELECT PCInfoAuditDataTableID, [User], Name FROM AuditDataTable

WHERE ([User] IN ('suwaa9,c5sina,dobraa,JOHNSTA,prasa9'))

 I want to return where there are any matches with the values 'suwaa9,c5sina,dobraa,JOHNSTA,prasa9'

I'm returning no records, but if I remove all but one of the parameters (JOHNSTA) I  get two results returned.

My syntax is wrong somewhere....

0
pizzamaker74
5/3/2009 4:51:08 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

6 Replies
452 Views

Similar Articles

[PageSpeed] 25

 

SELECT PCInfoAuditDataTableID, [User], Name FROM AuditDataTable

WHERE ([User] IN ('suwaa9','c5sina','dobraa','JOHNSTA','prasa9'))


-- "Mark As Answer" if my reply helped you --
0
gunteman
5/3/2009 5:00:45 PM

 

SELECT PCInfoAuditDataTableID, [User], Name FROM AuditDataTable

WHERE [User] IN ('suwaa9','c5sina','dobraa','JOHNSTA','prasa9')

0
Rangapure
5/3/2009 5:10:38 PM

 

Ok, if I need to post

'suwaa9','c5sina','dobraa','JOHNSTA','prasa9'  as a parameter in a stored procedure, how would l do it?

ie. my stored procedure is:

SELECT PCInfoAuditDataTableID, [User], Name

FROM AuditDataTable

WHERE ([User] IN (@userName))

 

and @userName is

'suwaa9','c5sina','dobraa','JOHNSTA','prasa9'

 

 

My stored procedure turns it into

DECLARE @return_value int

EXEC @return_value = [dbo].[usp_auditLastScansForUser_IN]

@userName = N'''suwaa9'',''c5sina'',''dobraa'',''JOHNSTA'',''prasa9'''

SELECT 'Return Value' = @return_value

GO

 

But it should turn it into:

('suwaa9','c5sina','dobraa','JOHNSTA','prasa9')

0
pizzamaker74
5/3/2009 5:28:48 PM

 Hi,pizzamaker

I would suggest u to use split function for that splitting U can refer

http://raghavkhunger.wordpress.com/2009/02/02/splitting-comma-delimited-string/ 


RAGHAV

MVP ASP/ASP.Net Read My Blog


MARK THE POST AS ANSWER IF IT HELPS U.


"Success doesn't come to you…you go to it."--Marva Collins




"Success does not come to those who wait . . . and it does not wait for anyone to come to it." Anonymous


0
raghav_khunger
5/3/2009 5:47:35 PM

 

I couldn't get that one to parse.

I ended up using the function at the bottom of this page:

http://www.nigelrivett.net/SQLTsql/InCsvStringParameter.html

0
pizzamaker74
5/4/2009 1:44:40 AM

 Hi,pizzamaker

I have given similar function that u are telling.Smile

 


RAGHAV

MVP ASP/ASP.Net Read My Blog


MARK THE POST AS ANSWER IF IT HELPS U.


"Success doesn't come to you…you go to it."--Marva Collins




"Success does not come to those who wait . . . and it does not wait for anyone to come to it." Anonymous


0
raghav_khunger
5/4/2009 5:04:52 AM
Reply:

Similar Artilces:

Multiple "AND" and "OR" Statements in an SQL Query
Hello,  I've got a table called "plants" which, up-until-recently, was being searched by category using the following SQL (and using the CategoryID field): SELECT plants.Latin_Name, Size.ekm_ID, plants.Common_Name, plants.Short_Description, plants.Thumb_URL, plants.CategoryID, plants.ProductID, Size.Size, Size.Price, Size.MostPopular FROM plants INNER JOIN Size ON plants.CategoryID = Size.CategoryID AND plants.ProductID = Size.ProductID WHERE (plants.CategoryID = @CategoryID) AND (Size.MostPopular = 'True') AND (Size.Availability = 'True') ORDER BY plants.Latin_Name  I now want ...

" union " + " order by " sql statement?
hi, It has error message " column 'CAT' not found " , when i compiled in Interactive SQL ASA7. sorry, my english is poor. ======= what's wrong the sql statement as the below. SQL: select '' as CAT, 'ALL' as DES union select cat,des from category group by cat,des order by cat I want the result is : CAT DES ------- ------ ALL C Cat C B Cat B : : The component SELECT statements must each have the same number of items in the select list, and cannot con...

"FIRST 10" or "TOP 10" for SQL statement?
To get the top 10 values in a table, is the proper syntax: SELECT FIRST 10 FROM... or is it: SELECT TOP 10 FROM... (MS SQL Server) ?Clay Shannon,author of historical works, novels, and art/poetryhttp://www.knowitallsports.com/booklinks.aspx Select Top 10.... Regards Mike [MVP - ASP/ASP.NET]My site...

"OUTPUT TO" Statement in "IF"
Hi All, I'm trying to execute the following statements: IF Condition THEN SELECT col FROM tbl; OUTPUT TO 'filename'; ELSE statements... END IF This gave me an error at 'SELECT' Can anyone tell me what is the correct approach? Thanks Stelios Stylianou > Hi All, > > I'm trying to execute the following statements: > IF Condition THEN > SELECT col FROM tbl; > OUTPUT TO 'filename'; > ELSE > statements... > END IF > > This gave me an error at 'SE...

What´s the purpose of "classifieds-categories.sql" "classifieds-add.sql""classifieds-remove.sql"?
 Hello all, what´s the purpose of the scripts I enunciated above on the classified starter kit?  "classifieds-categories.sql"  seems to create the initial parent categories, the others 2 names sugest they are used to add and remove ads, but i cant get how.There are 10 types of people in this world:Those who understand binary and those who don't. The classifieds starter kit is ready for upload right out of the box. Any .sql files you find in App_Data are scripts of the database.They are there to make it easy for uploading your site. So if you were not mak...

Precedence of "where" ("of", "is", "will")?
Nobody on #perl6 today could answer this one. Is: Str | Int where { $_ } the same as: (Str | Int) where { $_ } or: Str | (Int where { $_ }) ? Followup questions, Mr. President: What kind of operators are "where", "of", "is", and "will"? Is there a reason that S03 doesn't list them? What are their precedence(s)? -- Chip Salzenberg - a.k.a. - <chip@pobox.com> Open Source is not an excuse to write fun code then leave the actual work to others. Chip Salzenberg writes: &...

.ALLCOL("%COLUMN%", " ", ", ", ", ")
Do you know anyway for me to exclude a subset of columns returned by this function. We have two columns (rec_user and rec_datetime) which are in all of our tables, but when generating triggers I want automatically generate a script which does not include those two columns but does include all other columns in that table. Bruce I should add that I am using PD 9.0.0.580. Bruce "Bruce Lamb" <lamb.bruce@mayo.edu> wrote in message news:6HgI315nCHA.155@forums.sybase.com... > Do you know anyway for me to exclude a subset of columns returned by this > function. ...

How to give "And" and "OR" in my sql query?
      My layout (.aspx) have 3 TextBox and 2 Dropdownlist and 1 Button which just looks like Search KeyWord 【Texbox1】DorpDownList1 (have 2 items "And" and "Or")  【TextBox2】DorpDownList2 (have 2 items "And" and "Or") 【TextBox3】 Button ( this Button is for submit query)   1 "txtQuery" style="Z-INDEX: 101; LEFT: 152px; POSITION: absolute; TOP: 32px" runat="server" 2 Width="264px"> 3 "ddlBoolean" style="Z-INDEX: 102; LEFT: 152px; ...

SQL syntax opertators: "= any" and "= all"
Hi all, Does anyone ever use the operator of ANY and ALL in the data source of the datawindow? If yes, can you tell me what is the benefit and the context of how to use it? Thanks, Kevin Kevin, Guess you're using Oracle...Just saw that in my oracle Book.. For ANY..when testing for equivalence (= ANY (a,b,c..etc)), this is the same as IN For ALL, my docs say tests that relationship specified is true for every element of the list provided... HTH -- Evita R. Chapa Senior Systems Analyst II Command Technologies, Inc. "kdinh" <kdinh@cayenta...

regarding "in" and "=" in a SQL query
Hi, I am using a sybase database client . When i use "in" in a complex nested query say "select * from emp where emp_id in (select emp_id ..........)" then the execution time is really slow but in the same nested query when i use = as in "select * from emp where emp_id = (select emp_id ..........)", then the query is fast. Is there any particular reason for the same? Regards, Supreeth The obvious difference is that the "=" implies that the subquery can only return a single value as opposed to the "in" which implies that th...

quotes, quotes, quotes...
I am getting this error and I know what is causing it, but I have no idea how to fix it, any help would be great. The script steps through the /var/log/messages file on a linux server and puts The entries into a mysql database. However when it gets to the 'hlt' line in the messages file it just barfs. The single quotes are freaking it out. I know about quotes but not how to use in this situation. Thanks, Paul Error: May 27 17:53:00 localhost kernel: Checking 'hlt' instruction... OK. <----- doesn't like this in the messages file DBD::mysql::st exec...

wrong character display ("�" displays as "�" or "?")
Using ODBC Sybase 11 router, the character "�", saved in a varchar column in Sybase 11.5 will display as "�" or "?" in SQL Advantage or in our application. This just started occuring once we changed our applications to use 32 bit ODBC connection, rather than DBLib 16 bit. What is really interesting is that our our old 16 bit application runnning on the same PC returns the characters correctly, while 32 bit application running against ODBC returns another character, usually the degree symbol. Both versions of this program are accessing the same data sou...

sql for Financial Reporting periods "This Month", "Last Month", "This Quarter", "Last Quarter", "This Year", "Last Year"
Does anyone know of a way to use a funtion for returning records based on fiscal reporting periods like Quickbooks uses for example "This Month", "Last Month", "This Quarter", "Last Quarter", "This Year", "Last Year". While I realize that I can create a very long date time parsing routine  for this but it is not very elegant or useful. I thought there might be a way to do this already with an existing function.I have created a stored procedure that I pass a @ViewRange Parameter to and it returns the records that I want but I ne...

Wrong resultset with SQL statement with the function "cast" in the ORDER BY clause
Hi! i have simple sql query with the function "cast" in the ORDER BY clause. This query will return a wrong result set by using ODBC with asa 8.0.2. When i use the java ISQL, the results looks fine, but when i use the win32 ISQL i will get a wrong rs. Each row of the temp column will return the value "ONE". When i remove the ORDER BY clause the query works fine. I'm wondering because this query works with ASA 7.0.4. Has the behavior changed between 7.0.4 and 8.0.2 or is this a bug? Thanks, Carsten Rambow Here my query: Query: select test_id, test_f...

Web resources about - Is there something wrong with my "IN" statement? - asp.net.sql-datasource

Resources last updated: 1/15/2016 10:09:18 AM