dongtao1262 2015-07-23 10:36
浏览 88
已采纳

临时表创建

I am debuging php website and don't know how mysql query in it works. The code is:

$query = "
        SELECT
            WR.*,           
            W.*,
            D.*         
        FROM
            {#table} WR
        LEFT JOIN words W
            ON WR.word_id = W.word_id
        LEFT JOIN words_descriptions WD
            ON W.word_id = WD.word_id
        LEFT JOIN descriptions D
            ON WD.description_id = D.description_id
        " . $user_words_sql . "
        WHERE 
            title_len > 3
            AND W.in_game = 1
            " . $frequency_sql . " 
            " . $type_sql . "   
        GROUP BY 
            WR.word_id, 
            WR.description_id               
        ORDER BY
            $additional_order W.frequency DESC      
    ";

My question is where table WR is created, is it temporary table created in this peace of code or is it created somewhere else? Also, what this expression {#table} does?

  • 写回答

1条回答 默认 最新

  • douya2007 2015-07-23 10:50
    关注

    The value "WR" is an alias for the query, not a temporary table. It doesn't copy the data in memory, it's just a shortcut to make the query shorter/easier to read. Here's an example:

    SELECT * FROM countries c WHERE c.code = "GB"
    

    Expands to be:

    SELECT * FROM countries WHERE countries.code = "GB"
    

    @machineaddict was correct, the {#table} has no significance in MySQL - it's likely that this is being replaced at a later stage by another part of your PHP application.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置