I’m currently importing a dictionary in mysql which has words that are seperated by _. I wanted to know how to specify the words are seperated by _. For example the words are as such:
Super_Mario
Stack_Overflow
Another_Word
so each row would then be stored as :
Super Mario
Stack Overflow
Another Word
I have this query right now:
LOAD DATA LOCAL INFILE
C:/upload/dictionary.csv
INTO TABLE dictionary
fields terminated by ',' lines terminated by '\n'
would I have to use fields terminated by '_'?
No, you just use the
SETclause (just like in anUPDATE) to set the field’s value with the result of a stringREPLACE()operation that replaces underscores with spaces.The
(@var1)bit afterINTO TABLE dictionaryjust means “there’s only one column in the file I’m interested in, and I want to store it in@var1so I can use it later in mySETclause instead of putting it directly into a column.” Do a Ctrl+F in for “SET clause” in the documentation forLOAD DATA INFILEto see how to use aSETclause when your input file has more than one column.