0

I have written a mysql query which selects some rows from a table depending on a condition and writes it to a txt file. But i realized, its inserting a set of additional characters in the last line of the file. Here is the query

$sQuery  = " ( ";
            $sQuery .= " SELECT number ";
            $sQuery .= " INTO OUTFILE '".$outputfile_ndnd."' ";
            $sQuery .= " FIELDS TERMINATED BY ','  ";   
            $sQuery .= " LINES TERMINATED BY '\r\n' ";
            $sQuery .= " FROM `".$database."`.$temp_table_name";
            $sQuery .= " WHERE number NOT IN (SELECT number FROM `dnd`.`dnd` )";
            $sQuery .= ")";

Any suggestion to stop that from inserting in to file? (I saw the other similar questions asked, they say its UTF-8's BOM, but didnt get how to stop it in my case of mysql query)

vikram
  • 77
  • 8
  • Last line? They should be the first three bytes. – coladict Feb 23 '17 at 11:13
  • Yes, in last line, it should be a number, but its ending like is 9876543210, but i want only 9876543210. – vikram Feb 24 '17 at 04:38
  • I can't test this, but try adding `CHARACTER SET binary` after the outfile parameter, before `FIELDS TERMINATED BY`. It might disable the conversion. – coladict Feb 24 '17 at 08:59

0 Answers0