Home >Database >Mysql Tutorial >jsp查询mysql,表名是变量,需要前段输入,怎么实现

jsp查询mysql,表名是变量,需要前段输入,怎么实现

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 09:39:40976browse

mysqljsp

如题。。。。写了一个下午就是因为表名是变量无法实现。。。。

<code> stmt = conn.createStatement();  String sql="select * from "+table1+"where station='"+station1+"'";    ResultSet rs = stmt.executeQuery(sql);</code>
<code>这样不能连接但是</code>
<code>    String sql="select * from "+table1;    String sql="select * from sql201307 where station='"+station1+"'";</code>
<code>这两条就可以。。。真是不明白</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn