Contact Us
  
 
 
    SearchSearch   RegisterRegister   Log inLog in 

How to use select queries with array in mysql

How to use select queries with array in mysql

 
Post new topic   Reply to topic     Forum Index -> DataBase, RDBMS, MySql, Oracle, db2, SQL Server problems
View previous topic :: View next topic  
Author Message
amit



Joined: 17 Jan 2007
Posts: 8

PostPosted: Thu Jan 18, 2007 5:23 am    Post subject: How to use select queries with array in mysql Reply with quote




Hi,
I am using mysql + java servlet to develop my program. i have a problem of fetch data from table.I am storing my keys in vector or some what array, now i want to get data according to that keys. Keys are id in database. and size of my array may be around 5000. If i use e.g
Code:
 select * from tableName where clauses=10001 or clauses=10002 or clauses=10003 ....... clauses=15212.


if i use this kind of query, It will be stupid work and may it fail in future. Please anyone tell me, How to use array in select query in mysql.
e.g
Quote:

array={10001,10002,10003,10004,...... .....15212}
select * from tableName where clauses="+array+"
but it is not working in mysql.

Back to top
View user's profile Send private message
admin
Site Admin


Joined: 24 Aug 2006
Posts: 30

PostPosted: Sat Jun 28, 2008 3:23 pm    Post subject: How to use select queries with array in mysql Reply with quote

Hi,
We dont know about array support in mysql. But have many options and mysql provides instead of using array, in function, any function.

We have to make it like array to execute

Code:

 select * from tableName where clauses=10001 or clauses=10002 or clauses=10003 ....... clauses=15212.


Use like this

Code:

SELECT * FROM usermaster u where sUserID in('10001','10002','10003');
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DataBase, RDBMS, MySql, Oracle, db2, SQL Server problems All times are GMT
Page 1 of 1

 
Jump to:  
  Quick Post a Reply Topic
     
  Name (required)  
     
  Email Address (will not be published) (required)  
     
  Subject of topic (required)  
     
   
     
   
     
  Advertisement  
     
 
     


  More Links  
 
JSP Introduction
JSP Setup
Simple JSP Example
JSP Variable
Array Declaration in JSP
JSP Forms and User Input
Form Validation
JSP Cookies
JSP Session Object
Loop, content collection, iterator, conditional check in JSP
JSP Application Object
JSP Include
JSP Response Object
JSP Request Object
JSP Error Handling
JSP File Handling Object
JSP Action Tag
JSP Implicit Objects
JSP Declaration
JSP Directive
JDBC Introduction
JDBC Driver
JDBC Connection
JDBC Prepared/Statement
JDBC ResultSet
JDBC Close Connection object
JDBC Insert
JDBC Display Records
JDBC Update
JDBC Delete
JDBC Sorting
JDBC Query
JDBC Exception
JDBC Add Batch
JDBC Transaction/RollBack