列名称不明确'Year'

时间:2018-09-07 19:30:31

标签: sql sql-server

我有一个带有列Year的表,我需要编写一个存储过程来获取当年的所有记录。

编写存储过程时,出现标题中提到的错误。

有没有解决的办法?

2 个答案:

答案 0 :(得分:1)

也许这会有所帮助。

select mytable.[year] from mytable where mytable.[year] > 2007 列括在方括号中,并使用表名进行引用。

import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker.State;
import javafx.embed.swing.JFXPanel;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebErrorEvent;
import javafx.scene.web.WebEvent;
import javafx.scene.web.WebView;
import javafx.util.Callback;

import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.swing.*;

import org.w3c.dom.Document;

public class LoginApplicationWindow {

    public static void main(String args[]) {
        final JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setSize(620, 440);
        final JFXPanel fxpanel = new JFXPanel();
        frame.add(fxpanel);

        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                WebEngine engine;               
                WebView wv = new WebView();
                engine = wv.getEngine();
                engine.setJavaScriptEnabled(true);

                 // Create a trust manager that does not validate certificate chains
                TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {

                    @Override
                    public X509Certificate[] getAcceptedIssuers() {
                        // TODO Auto-generated method stub
                        return null;
                    }

                    @Override
                    public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                        // TODO Auto-generated method stub

                    }

                    @Override
                    public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                        // TODO Auto-generated method stub

                    }
                }};

                // Install the all-trusting trust manager
                SSLContext sc;
                try {
                    sc = SSLContext.getInstance("SSL");
                    sc.init(null, trustAllCerts, new java.security.SecureRandom());
                    HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
                } catch (NoSuchAlgorithmException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (KeyManagementException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }


                // Create all-trusting host name verifier
                HostnameVerifier allHostsValid = new HostnameVerifier() {

                    @Override
                    public boolean verify(String hostname, SSLSession session) {
                        // TODO Auto-generated method stub
                        return true;
                    }
                };

                // Install the all-trusting host verifier
                HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);

                engine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
                      public void changed(ObservableValue ov, State oldState, State newState) {
                        if (newState == State.SUCCEEDED) {
                          Document doc = engine.getDocument();
                          // operations on dom occur here.
                          System.out.println(engine.getLoadWorker().exceptionProperty());
                          System.out.print("load finished " + doc.getBaseURI());
                        }
                      }
                });


                engine.setOnAlert(new EventHandler<WebEvent<String>>() {

                    @Override
                    public void handle(WebEvent<String> event) {
                        System.out.print("setOnAlert " + event.getData());
                    }
                });

                engine.setOnError(new EventHandler<WebErrorEvent>() {

                    @Override
                    public void handle(WebErrorEvent event) {
                        System.out.print("onError " + event.getMessage());
                    }
                });

                engine.setConfirmHandler(new Callback<String, Boolean>() {

                    @Override
                    public Boolean call(String param) {
                        // TODO Auto-generated method stub
                        System.out.print("setConfirmHandler " + param);
                        return null;
                    }
                });


                fxpanel.setScene(new Scene(wv));
                engine.load("https://login.microsoftonline.com");
                //engine.load("https://facebook.com");

            }
        });
        frame.setVisible(true);
    }
}

答案 1 :(得分:0)

通常,这意味着您有两个表,并且都有一个“年”列,并且您在引用其中一个表时没有说出它来自哪个表。给它起一个别名。另外,您应该提供有关问题的更多信息(并且不要将保留字用作列名)