One column CSV -> IN () block


Last edited by KogAdmin
Thu, 19 Jan 2006 15:54 PST [diff]


I seem to have to do this quite frequently... It's a lovely hack around MySQL < 4.1 not having subselects. I end up dumping the 1 column of my search to CSV via phpMyAdmin (yeah... everyone does seem to use it, don't they) and then end up doing some hand editing. One day I realized I can just VIM script it.

The goods
:%s/\"//g
:%s/$/,/g
:%j
$v$d
:%s/^/IN (/g
:%s/$/)/g


Script files
Well, so far this is a macro. Not sure if macros persist, or if you can save them (or if those are just scripts?). I need to read more, but don't currently have time.


This page is CategoryHowTo
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki