开发者

DB2 Select Query with data in file

开发者 https://www.devze.com 2023-04-06 17:28 出处:网络
Lets say I have a csv file(ids.csv) with ids like 101,102,103......1MILLION I wanted to select data from the table by reading ids from file in the where clause

Lets say I have a csv file(ids.csv) with ids like

101,102,103......1MILLION

I wanted to select data from the table by reading ids from file in the where clause

Something like

select * from employee where id in (<I wanted to read ids from external csv file>)

Is this possible in any database. I am interested in db2.

Due to limitation in character length in sql if i put all these ids in in clause its not allowing to run a que开发者_Python百科ry. Right now I am chunking ids in to smaller set and running the query.


Import the data into a table using the DB2 IMPORT command.

It will be something like:

db2 import from ids.csv of del create into id_table

You can read more about the command at the above link.

Once that's done it's a simple matter of:

select * from employee where id in (select id from id_table)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号