首頁  >  文章  >  後端開發  >  这句sql哪里出错了呀。

这句sql哪里出错了呀。

WBOY
WBOY原創
2016-06-06 20:37:38808瀏覽

$sql="select * from student where studentid={$studentid} and likeclassid={$classid}";

PS:likeclassid 是一个完整的字段名

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 'and likeclassid=1176' at line 1

回复内容:

$sql="select * from student where studentid={$studentid} and likeclassid={$classid}";

PS:likeclassid 是一个完整的字段名

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 'and likeclassid=1176' at line 1

把大括号去掉 而且like后面少空格 匹配格式也不对

语法上应为 classid like {$classid}
但既然是like了就要模糊匹配,取决于你想匹配的内容使用%,*。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn