从一个表复制另一个表中的数据时,不会对数据进行排序吗?

时间:2017-03-29 16:00:12

标签: mysql

有两个表格cnmdcnmd2具有相同的结构。我想复制cnmdcnmd2的所有数据,按md_cnchar中的字符数排序SELECT `md_id`, `md_lesson`, `md_topics`, `md_level`, `md_cnchar`, `md_pytone`, `md_pytone_ws`, `md_pytone_n`, `md_pytone_n_ws`, `md_pinyin`, `md_pinyin_ws`, `md_engword`, `md_sound`, `md_hints` FROM `cnmd` WHERE 1 ORDER BY CHAR_LENGTH(md_cnchar); }。

md_cnchar

这项工作适合按INSERT INTO `cnmd2`(`md_id`, `md_lesson`, `md_topics`, `md_level`, `md_cnchar`, `md_pytone`, `md_pytone_ws`, `md_pytone_n`, `md_pytone_n_ws`, `md_pinyin`, `md_pinyin_ws`, `md_engword`, `md_sound`, `md_hints`) SELECT `md_id`, `md_lesson`, `md_topics`, `md_level`, `md_cnchar`, `md_pytone`, `md_pytone_ws`, `md_pytone_n`, `md_pytone_n_ws`, `md_pinyin`, `md_pinyin_ws`, `md_engword`, `md_sound`, `md_hints` FROM `cnmd` WHERE 1 ORDER BY CHAR_LENGTH(md_cnchar); 中的字符数排序。 但是..

md_cnchar

这不适用于按md_id中的字符数排序。

已解决问题:在查询中移除自动增量键INSERT INTO `cnmd2`( `md_lesson`, `md_topics`, `md_level`, `md_cnchar`, `md_pytone`, `md_pytone_ws`, `md_pytone_n`, `md_pytone_n_ws`, `md_pinyin`, `md_pinyin_ws`, `md_engword`, `md_sound`, `md_hints`) SELECT `md_lesson`, `md_topics`, `md_level`, `md_cnchar`, `md_pytone`, `md_pytone_ws`, `md_pytone_n`, `md_pytone_n_ws`, `md_pinyin`, `md_pinyin_ws`, `md_engword`, `md_sound`, `md_hints` FROM `cnmd` ORDER BY CHAR_LENGTH(md_cnchar);

string path = Environment.CurrentDirectory + "/" + "latlong.txt";

private void button1_Click(object sender, EventArgs e)
{
    if (!File.Exists(path))
    {
        File.CreateText(path);
        MessageBox.Show("File has been created.");
    }
}

private void button2_Click(object sender, EventArgs e)
{
    using (StreamWriter stwr = new StreamWriter(path))
    {
        for (int i = 0; i < listBox1.Items.Count; i++)
        {
            stwr.WriteLine("googleMap.addMarker(new MarkerOptions().position(new LatLng(" + listBox1.Items[i] + ", " + "ii" + ")).title(" + "bbb" + "));");
        }
        stwr.Close();
        string text = File.ReadAllText("latlong.txt");
        for (int ii = 0; ii < listBox2.Items.Count; ii++)
        {

            text = text.Replace("ii", Convert.ToString(listBox2.Items[ii]));
        }
        File.WriteAllText("latlong.txt", text);
    }
}

0 个答案:

没有答案