sql创建表主键错误1064

当前访客身份:游客 [
:引用来自“小萝莉菜鸟”的评论还是不行呢?但是我...
:还是不行呢?但是我用浏览器可以把这个东西下载下...
:自己回答下: @Override public int getItemPosi...
:感谢啊~~~顺利解决问题了
:引用来自“ArtShell”的评论 引用来自“wzfz”的...
:引用来自“wzfz”的评论 form 如果是get 方式提交...
:form 如果是get 方式提交如果action是search?ke...
:前段时间也这样用过
今日访问:74
昨日访问:95
本周访问:338
本月访问:1061
所有访问:14748
MySQL创建一个简单的存储过程,报错;SQL Error (1064)
发表于2年前( 09:26)&&
阅读(1016)&|&评论()
0人收藏此文章,
MySQL创建存储过程-报错:
SQL Error (1064): You have an error in your SQL check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3
CREATE PROCEDURE AvgFruitPrice4()
SELECT AVG(f_price) AS avgprice
解决方法1:
delimiter $$
CREATE PROCEDURE AvgFruitPrice4()
SELECT AVG(f_price) AS avgprice
解决方法2:
CREATE PROCEDURE AvgFruitPrice4()
SELECT AVG(f_price) AS avgprice
更多开发者职位上
1)">1)">1" ng-class="{current:{{currentPage==page}}}" ng-repeat="page in pages"><li class='page' ng-if="(endIndex<li class='page next' ng-if="(currentPage
相关文章阅读Stack Overflow is a question and answer site for professional and enthusiast programmers. It&#39;s 100% free.
I am creating a website for a university assignment and i have run into a snag while writing some PHP for email address and password change and this error has come up and i can't for the life of me figure out what the issue is.
Error code:
Failed to run query3: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE username = chris' at line 1
// First we execute our common code to connection to the database and start the session
require("common.php");
// At the top of the page we check to see whether the user is logged in or not
if(empty($_SESSION['user']))
// If they are not, we redirect them to the login page.
header("Location: login.php");
// Remember that this die statement is absolutely critical.
Without it,
// people can view your members-only content without logging in.
die("Redirecting to login.php");
$username = $_SESSION['user']['username'];
if(!empty($_POST))
//check for valid email
if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
$emailInvalid =
$emailInvalidAmmount = 1;
//Check if the new E-mail matches existing E-mail address, if it does no action is needed
if($_POST['email'] !=$_SESSION['user']['email'])
$query = "SELECT 1 FROM users WHERE email = :email";
$query_params = array (':email' =& $_POST['email']);
$stmt = $db-&prepare($query);
$result = $stmt-&execute($query_params);
catch(PDOException $ex)
die("Failed to run query1: " . $ex-&getMessage());
//retrieve results and check if new E-mail address exists in the database
$row = $stmt-&fetch();
$emailExists =
$emailExistsAmmount = 1;
$query ="SELECT password, salt FROM users WHERE username = :username";
$query_params = array(':username' =& $username);
$stmt = $db-&prepare($query);
$result = $stmt-&execute($query_params);
catch(PDOException $ex)
die("Failed to run query2: " . $ex-&getMessage());
$row = $stmt-&fetch();
$check_password = hash('sha256', $_POST['currentPassword'] . $row['salt']);
for($round = 0; $round & 65536; $round++)
$check_password = hash('sha256', $check_password . $row['salt']);
if($check_password == $row['password'])
$password_ok =
if($password_ok = true)
$newPassword = $_POST['newPassword'];
$confirmPassword = $_POST['confirmPassword'];
if($newPassword == $confirmPassword)
$salt = dechex(mt_rand(0, )) . dechex(mt_rand(0, ));
$password = hash('sha256', $_newPassword . $salt);
for($round = 0; $round &65536; $round++)
$password = hash('sha256', $password . $salt);
$query ="INSERT INTO users (password, salt) VALUES (:password, :salt)";
$query .= "WHERE username = $username";
$query_params = array(':password' =& $password, ':salt' =& $salt);
$stmt = $db-&prepare($query);
$result = $stmt-&execute($query_params);
catch(PDOException $ex)
die("Failed to run query3: " . $ex-&getMessage());
$passwordChanged =
Any help would be much appreciated. Thanks
Since this is for an assignment, I'll be vague.
Make sure you're properly parameterizing all of the variables you're including in all of your queries.
6,65511127
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you&#39;re looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledStack Overflow is a question and answer site for professional and enthusiast programmers. It&#39;s 100% free.
I am trying to populate a new MySQL empty database with a db dump created from MS SQL Azure database, and I get the following error
ERROR ) at line 1: You have an error in your SQL
Check the manual that corresponds to your MySQL server version for the
right syntax to use near 'I ' at line 1
I used mysqldump to perform this operation and used command similar to the following in the command prompt:
mysql --user=rootusername --pasword=password databasename & dumpfilename.sql
Mysqldump took about 30 minutes to display this error message.
2,833135289
Do you have a specific database selected like so:
USE database_name
Except for that i cant think of any reason for this error.
5,01432449
I ran into this once - for me, deleting all the commented out lines at the beginning of my dump file is what fixed the problem.
Looks like it was a whitespace error.
Check your dump file. Looks like a stray character at the beginning. SQL isn't standard the world around, and the MySQL importer expects MySQL-friendly SQL. I'm willing to bet that your exporter did something funky.
You may have to massage the file a bit to get it to work with MySQL.
3,84811937
I had this, and it was the create syntax, changed to --create-options and life was better
mysqldump -u [user] -p -create-options [DBNAME] &[DumpFile].sql
And that restored nicely.
(For those coming to this question from a search engine), check that your stored procedures declare a custom delimiter, as this is the error that you might see when the engine can't figure out how to terminate a statement:
ERROR ) at line 3: You have an error in your SQL
check the manual that corresponds to your MySQL server version for the
right syntax to use near '' at line…
If you have a database dump and see:
DROP PROCEDURE IF EXISTS prc_
CREATE PROCEDURE prc_test( test varchar(50))
SET @sqlstr = CONCAT_WS(' ', 'CREATE DATABASE',
test, 'CHARACTER SET utf8 COLLATE utf8_general_ci');
PREPARE stmt FROM @
Try wrapping with a custom DELIMITER:
DROP PROCEDURE IF EXISTS prc_
DELIMITER $$
CREATE PROCEDURE prc_test( test varchar(50))
SET @sqlstr = CONCAT_WS(' ', 'CREATE DATABASE',
test, 'CHARACTER SET utf8 COLLATE utf8_general_ci');
PREPARE stmt FROM @
DELIMITER ;
ERROR ) at line 1:
This error is very common. The main reason of the occurrence of this error is: When user accidentally edited or false edit the .sql file.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you&#39;re looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledsql 错误 1064_百度知道
sql 错误 1064
create table train times( departstime, arrivestime, startlocatin varchar(&75&), destination varchr(&75&));返回You have an error in your SQL check the manual that corresponds to your MySQL server version for the right syntax to use near &#39;times(departstime,arrivestime,startlocatin varchar(&75&),destination v&#39; at line 1
是什么原因
提问者采纳
在SQL 中,表的名字中不能出现空格等特殊字符,你这里的train times列车时刻,应该是一个连续的名字,有了空格,系统会认为是两个部分,所以错了。类似这种情况在中间加下划线是通用的做法。改成train_times就没问题了。
其他类似问题
为您推荐:
其他3条回答
create table &#39;train times&#39;( departstime, arrivestime, startlocatin varchar(75), destination varchr(75));
改为create table train_times( departstime int(10), arrivestime int(10), startlocatin varchar(&75&), destination varchr(&75&)); 如果非要train times这个表名,请改为create table `train times`( departstime int(10), arrivestime int(10), startlocatin varchar(&75&), destination varchr(&75&));
create table train times创建表名有误是不是想创建表traintimes
您可能关注的推广回答者:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁sql语句报错: #1064 - ,是什么地方的错误呢?_百度知道
sql语句报错: #1064 - ,是什么地方的错误呢?
这个创建mysql数据表的sql语句,哪里有错误呢?create table if not EXISTS `ktv_activity`( `id` int(4) unsigned not null auto_increment, `name` varchar(500) not null COMMENT &#39;活动名称&#39;, `picture` varchar(500) not null COMMENT &#39;活动图片&#39;, `activityTime` VARCHAR(50) not null COMMENT &#39;活动时间&#39;,
`address` text not null COMMENT &#39;活动地点&#39;, `cellphone` VARCHAR(50) not null &#39;报名电话&#39;, PRIMARY KEY( id ))DEFAULT CHARset=utf8;
提问者采纳
报名电话前边没写 commentcreate&table&if&not&EXISTS&`ktv_activity`(&`id`&int(4)&unsigned&not&null&auto_increment,&`name`&varchar(500)&not&null&COMMENT&&#39;活动名称&#39;,&`picture`&varchar(500)&not&null&COMMENT&&#39;活动图片&#39;,&`activityTime`&VARCHAR(50)&not&null&COMMENT&&#39;活动时间&#39;,&&`address`&text&not&null&COMMENT&&#39;活动地点&#39;,&`cellphone`&VARCHAR(50)&not&null&COMMENT&&#39;报名电话&#39;,PRIMARY&KEY(&id&))DEFAULT&CHARset=utf8;
提问者评价
其他类似问题
为您推荐:
其他1条回答
--id那行没加comment --另外整那么多没用的干嘛create table ktv_activity(id int(4) not null ,name varchar(500) not null ,picture varchar(500) not null ,activityTime VARCHAR(50) not null ,address text not null ,cellphone VARCHAR(50) not null ,PRIMARY KEY( id ));
您可能关注的推广回答者:
sql语句的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁}

我要回帖

更多关于 sql创建表主键 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信