Unsupported Screen Size: The viewport size is too small for the theme to render properly.

Row Order On Csv Import

forums forums SQLyog Using SQLyog Row Order On Csv Import

  • This topic is empty.
Viewing 2 reply threads
  • Author
    Posts
    • #9998
      Tony H.
      Member

      Hi all

      I'm having some trouble with importing data from a CSV file. Well, actually the data iteself imports just fine, but the order of the rows seems to be totally random. Now MySQL is just fine with the rows of data being in some random order, but unfortunately when I then export that data back out the order IS important. (just as an FYI, I'm sending data back and forth between a MySQL database and a custom in-house application that reads CSV files and processes the data starting from the top).

      Is there any way to ensure that SQLyog imports data from a CSV file in order?

      Alternatively, is there another easy way to export data and then import it back and make sure that the row order is maintained?

      Or, if neither of those options will work, is there a way to export a result set in the order in which it is displayed in SQLyog rather than how it is being stored in the database? When I import my data and the rows are all out of order, I can sort it in SQLyog by just clicking on one of the columns. However if I then make some changes and re-export the data, the rows are exported in the same (dis)order from when they were imported.

      Any help would be greatly appreciated!

      Tony

      ps. SQLyog version is 5.19. MySQL version 5.0.24a.

    • #22872
      peterlaursen
      Participant

      when you click the title bar to sort data is affects only how data are displayed.

      Actually SQL databases are not designed in a way so that 'raw order' matters. It also depends on the storage Engine (myISAM/InnoD:cool: whether 'unused space' are filled with data or not.

      Basically you are supposed to use and ORDER BY clause when generating a result set. You export and import and keep the order you could try

      Code:
      SELECT INTO OUTFILE …. ORDER BY…

      that will generate a sorted SQL-file. But how the server stores the data when they are stored, SQLyog cannot control!

    • #22873
      Tony H.
      Member
      peterlaursen wrote on Oct 30 2006, 12:21 AM:
      Basically you are supposed to use and ORDER BY clause when generating a result set. You export and import and keep the order you could try

      Code:
      SELECT INTO OUTFILE …. ORDER BY…

      that will generate a sorted SQL-file. But how the server stores the data when they are stored, SQLyog cannot control!

      Hi Peter

      Thanks for the reply! I hadn't even thought about doing a simple ORDER BY query, but it should work just fine!

      Thanks!

      Tony

Viewing 2 reply threads
  • You must be logged in to reply to this topic.