我正在尝试向此查询添加where语句,因此它只显示已设置为已发布的记录。
$query = "SELECT id, heading, summary, date, keyword1, keyword2, keyword3
FROM " . DB_TABLE . "";
我试过
$query = "SELECT id, heading, summary, date, keyword1, keyword2, keyword3, publish
WHERE publish ='y' FROM " . DB_TABLE . "";
和
$query = "SELECT `id`, `heading`, `summary`, `date`, `keyword1`, `keyword2`, `keyword3`, `publish`
WHERE `publish` ='y' FROM " . DB_TABLE . "";
但是他们似乎都没有工作,任何帮助都非常感谢,谢谢
答案 0 :(得分:3)
这个怎么样:
$query = "SELECT `id`, `heading`, `summary`, `date`, `keyword1`, `keyword2`, `keyword3`, `publish` FROM " . DB_TABLE . " WHERE `publish` ='y' ";
如果您查看MySQL documentation,您会看到SELECT
语句首先出现,然后FROM
语句和WHERE
最后出现。当然可以使用其他各种语句,您可以在上面的链接中找到所有这些语句