SQL 查询中有关引号的错误
Error in SQL Query regarding inverted commas
我正在 运行 关注 php 中的查询:
$link = $_GET['link'];
$query = "SELECT DISTINCT sub_category FROM phonebook ORDER BY sub_category WHERE category = '$link' ";
echo $query;
$sql = mysql_query($query) or die(mysql_error());
并且出现以下错误:
SELECT DISTINCT sub_category FROM phonebook ORDER BY sub_category WHERE category = 'Administration' 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 'WHERE category = 'Administration'' at line 1
我无法理解引号中的错误是什么?
尝试以下操作:
$query = "SELECT DISTINCT sub_category FROM phonebook ORDER BY sub_category WHERE category = '$link' ";
进入
$query = "SELECT DISTINCT sub_category FROM phonebook WHERE category = '".$link."' ORDER BY sub_category ";
你犯了错误"sub_caregory":
$query = "SELECT DISTINCT sub_caregory FROM phonebook WHERE category = '".$link."' ORDER BY sub_caregory ";
ORDER BY 应该在 where close 之后
你做不到
SELECT
FROM
OREDER BY
WHERE
订单是
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
试试下面的查询:
$query = "SELECT DISTINCT sub_category FROM phonebook WHERE category = '".$link."' ORDER BY sub_category";
要查看完整的 select 声明,您可以在此处查看 http://dev.mysql.com/doc/refman/5.7/en/select.html
我正在 运行 关注 php 中的查询:
$link = $_GET['link'];
$query = "SELECT DISTINCT sub_category FROM phonebook ORDER BY sub_category WHERE category = '$link' ";
echo $query;
$sql = mysql_query($query) or die(mysql_error());
并且出现以下错误:
SELECT DISTINCT sub_category FROM phonebook ORDER BY sub_category WHERE category = 'Administration' 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 'WHERE category = 'Administration'' at line 1
我无法理解引号中的错误是什么?
尝试以下操作:
$query = "SELECT DISTINCT sub_category FROM phonebook ORDER BY sub_category WHERE category = '$link' ";
进入
$query = "SELECT DISTINCT sub_category FROM phonebook WHERE category = '".$link."' ORDER BY sub_category ";
你犯了错误"sub_caregory":
$query = "SELECT DISTINCT sub_caregory FROM phonebook WHERE category = '".$link."' ORDER BY sub_caregory ";
ORDER BY 应该在 where close 之后 你做不到
SELECT
FROM
OREDER BY
WHERE
订单是
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
试试下面的查询: $query = "SELECT DISTINCT sub_category FROM phonebook WHERE category = '".$link."' ORDER BY sub_category"; 要查看完整的 select 声明,您可以在此处查看 http://dev.mysql.com/doc/refman/5.7/en/select.html