查询返回false PHP

时间:2016-05-11 21:34:37

标签: mysql

我遇到MySQL查询问题。查询如下:

SET @catlocation = (SELECT id FROM categories WHERE url_name='hexcode');

SELECT
subs.display_name AS display,
subs.url_name AS url,
(
    SELECT title
    FROM threads
    WHERE location = subs.id
    ORDER BY time_submitted DESC
    LIMIT 1
) AS title,
( 
    SELECT username
    FROM users
    WHERE uid = (
        SELECT uid
        FROM threads
        WHERE location = subs.id
        ORDER BY time_submitted DESC
        LIMIT 1
    )
    LIMIT 1
) AS author,
(
    SELECT COUNT(*)
    FROM threads
    WHERE location = subs.id
    ORDER BY time_submitted DESC
    LIMIT 1
) AS thread_count

FROM ( 
    SELECT * 
    FROM categories 
    WHERE parent_id = @catlocation 
) AS subs

当我尝试通过PHP运行时,我得到一个错误的结果和错误:

  

您的SQL语法有错误;查看与您的MySQL服务器版本相对应的手册,以便在