![](/img/trans.png)
[英]Why is this ALTER TABLE MYSQL query not executing(returning false)? The syntax appears correct
[英]what is the correct syntax for MySQL alter table query?
當我嘗試運行以下mysqli調用時
$strSQL3=mysqli_query($connection," alter table mark_list add column 'mark' int(2) " ) or die(mysqli_error($connection));
返回錯誤
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near `mark int(2)` at line 1
單引號( '
)表示字符串文字。 對象名稱(例如列)不是字符串-突出號將引起引號:
$strSQL3 = mysqli_query($connection ,"alter table mark_list add column mark int(2)" ) or die(mysqli_error($connection));
嘗試更改“標記”以這樣標記 :
$strSQL3=mysqli_query($connection,
" alter table mark_list add column mark int(2) " )
or die(mysqli_error($connection));
只需刪除'
標記附近的引號
$strSQL3=mysqli_query($connection," alter table mark_list add column mark int(2) " ) or die(mysqli_error($connection));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.