MySQL自然连接的别名错误;

时间:2017-10-16 16:52:30

标签: mysql

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;

public class WriterFile {
    public void writing() {
        try {
            //Whatever the file path is.
            File statText = new File("statsTest.txt");
            FileOutputStream is = new FileOutputStream(statText);
            OutputStreamWriter osw = new OutputStreamWriter(is);    
            Writer w = new BufferedWriter(osw);
            w.write("Write to file !!!!");
            w.close();
        } catch (IOException e) {
            System.err.println("Something went wrong !!!");
        }
    }

    public static void main(String[]args) {
        WriterFile write = new WriterFile();
        write.writing();
    }
}

它给了我"每个衍生的表必须拥有自己的别名"。

它有什么问题。我找不到帮助!

1 个答案:

答案 0 :(得分:2)

只需在子查询中添加一个别名:

select t.name, t.course_id from (select * from takes where year>=2008) as t natural join student;