Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
How to format content of a file to fit a SQL in-clause
SUBMITTED BY:
Guest
DATE:
Sept. 23, 2013, 1:41 p.m.
FORMAT:
Bash
SIZE:
524 Bytes
Raw
Download
Tweet
HITS:
1978
Go to comments
Report
# How to format content of a file to fit a SQL in-clause:
# file: username
# with content:
username1
username2
username3
username4
username5
# This is how to make it fit the SQL in clause:
sed
"s/^/'/;s/
$
/',/;
$
s/,
$
//"
username
# output looks like:
'username1'
,
'username2'
,
'username3'
,
'username4'
,
'username5'
# now use output in your SQL statement
select
*
from
users
where
user_name
in
(
<insert
output
here>
)
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus