<bdo id='Faqxk'></bdo><ul id='Faqxk'></ul>
    1. <tfoot id='Faqxk'></tfoot>

        <small id='Faqxk'></small><noframes id='Faqxk'>

        <legend id='Faqxk'><style id='Faqxk'><dir id='Faqxk'><q id='Faqxk'></q></dir></style></legend>
        <i id='Faqxk'><tr id='Faqxk'><dt id='Faqxk'><q id='Faqxk'><span id='Faqxk'><b id='Faqxk'><form id='Faqxk'><ins id='Faqxk'></ins><ul id='Faqxk'></ul><sub id='Faqxk'></sub></form><legend id='Faqxk'></legend><bdo id='Faqxk'><pre id='Faqxk'><center id='Faqxk'></center></pre></bdo></b><th id='Faqxk'></th></span></q></dt></tr></i><div id='Faqxk'><tfoot id='Faqxk'></tfoot><dl id='Faqxk'><fieldset id='Faqxk'></fieldset></dl></div>
      1. LEFT JOIN 订单和限价

        时间:2023-10-09

          <small id='zIfSQ'></small><noframes id='zIfSQ'>

        • <tfoot id='zIfSQ'></tfoot>
          • <legend id='zIfSQ'><style id='zIfSQ'><dir id='zIfSQ'><q id='zIfSQ'></q></dir></style></legend>
            • <bdo id='zIfSQ'></bdo><ul id='zIfSQ'></ul>

              1. <i id='zIfSQ'><tr id='zIfSQ'><dt id='zIfSQ'><q id='zIfSQ'><span id='zIfSQ'><b id='zIfSQ'><form id='zIfSQ'><ins id='zIfSQ'></ins><ul id='zIfSQ'></ul><sub id='zIfSQ'></sub></form><legend id='zIfSQ'></legend><bdo id='zIfSQ'><pre id='zIfSQ'><center id='zIfSQ'></center></pre></bdo></b><th id='zIfSQ'></th></span></q></dt></tr></i><div id='zIfSQ'><tfoot id='zIfSQ'></tfoot><dl id='zIfSQ'><fieldset id='zIfSQ'></fieldset></dl></div>

                    <tbody id='zIfSQ'></tbody>
                  本文介绍了LEFT JOIN 订单和限价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是我的查询:

                  SELECT `p`.`name` AS 'postauthor', `a`.`name` AS 'authorname',
                         `fr`.`pid`, `fp`.`post_topic` AS 'threadname', `fr`.`reason`
                    FROM `z_forum_reports` `fr`
                    LEFT JOIN `forums` `f` ON (`f`.`id` = `fr`.`pid`)
                    LEFT JOIN `forums` `fp` ON (`f`.`first_post` = `fp`.`id`) 
                    LEFT JOIN `ps` `p` ON (`p`.`id` = `f`.`author_guid`)
                    LEFT JOIN `ps` `a` ON (`a`.`account_id` = `fr`.`author`)
                  

                  我的问题是这个左连接:

                  My problem is this left join:

                  SELECT `a`.`name`, `a`.`level`
                  [..]
                  LEFT JOIN `ps` `a` ON (`a`.`account_id` = `fr`.`author`)
                  

                  因为,如果 a 有很多行,它会像我的情况一样返回:

                  Since, in case a has MANY rows and it'll return like in my case:

                  NAME  | LEVEL
                  Test1 | 1
                  Test2 | 120
                  Test3 | 2
                  Test4 | 1 
                  

                  我希望它选择 a.nameorder 级别 desc 并限制为 1,所以它会返回更高的名称level where (a.account_id = fr.author).

                  I want it to select a.name with order of level desc and limit 1, so it'll return the name of higher level where (a.account_id = fr.author).

                  希望你能抓住我.如果没有,请随时发表评论.

                  Hope you got me. If not, feel free to post a comment.

                  推荐答案

                  尝试替换:

                  LEFT JOIN ps a ON a.account_id = fr.author
                  

                  与:

                  LEFT JOIN ps a 
                    ON a.PrimaryKey                         --- the Primary Key of ps
                       = ( SELECT b.PrimaryKey 
                           FROM ps AS b 
                           WHERE b.account_id = fr.author
                           ORDER BY b.level DESC
                           LIMIT 1
                         )
                  

                  这篇关于LEFT JOIN 订单和限价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:oracle sql中join关键字和inner join关键字有什么区别? 下一篇:SQL 连接子查询

                  相关文章

                1. <tfoot id='T5Sc1'></tfoot>
                  • <bdo id='T5Sc1'></bdo><ul id='T5Sc1'></ul>
                2. <small id='T5Sc1'></small><noframes id='T5Sc1'>

                  <legend id='T5Sc1'><style id='T5Sc1'><dir id='T5Sc1'><q id='T5Sc1'></q></dir></style></legend>

                    <i id='T5Sc1'><tr id='T5Sc1'><dt id='T5Sc1'><q id='T5Sc1'><span id='T5Sc1'><b id='T5Sc1'><form id='T5Sc1'><ins id='T5Sc1'></ins><ul id='T5Sc1'></ul><sub id='T5Sc1'></sub></form><legend id='T5Sc1'></legend><bdo id='T5Sc1'><pre id='T5Sc1'><center id='T5Sc1'></center></pre></bdo></b><th id='T5Sc1'></th></span></q></dt></tr></i><div id='T5Sc1'><tfoot id='T5Sc1'></tfoot><dl id='T5Sc1'><fieldset id='T5Sc1'></fieldset></dl></div>