久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <bdo id='vKxjO'></bdo><ul id='vKxjO'></ul>
<legend id='vKxjO'><style id='vKxjO'><dir id='vKxjO'><q id='vKxjO'></q></dir></style></legend>

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

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

    1. 在同一列上使用多個(gè) WHERE 條件進(jìn)行選擇

      SELECTING with multiple WHERE conditions on same column(在同一列上使用多個(gè) WHERE 條件進(jìn)行選擇)

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

          <bdo id='xwpbD'></bdo><ul id='xwpbD'></ul>
            <tbody id='xwpbD'></tbody>
              <tfoot id='xwpbD'></tfoot>
            1. <small id='xwpbD'></small><noframes id='xwpbD'>

            2. <legend id='xwpbD'><style id='xwpbD'><dir id='xwpbD'><q id='xwpbD'></q></dir></style></legend>

                本文介紹了在同一列上使用多個(gè) WHERE 條件進(jìn)行選擇的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                好吧,我想我可能在這里忽略了一些明顯/簡(jiǎn)單的東西...但我需要編寫一個(gè)查詢,該查詢僅返回與同一列上的多個(gè)條件匹配的記錄...

                Ok, I think I might be overlooking something obvious/simple here... but I need to write a query that returns only records that match multiple criteria on the same column...

                我的表是一個(gè)非常簡(jiǎn)單的鏈接設(shè)置,用于將標(biāo)志應(yīng)用到用戶......

                My table is a very simple linking setup for applying flags to a user ...

                ID   contactid  flag        flag_type 
                -----------------------------------
                118  99         Volunteer   1 
                119  99         Uploaded    2 
                120  100        Via Import  3 
                121  100        Volunteer   1  
                122  100        Uploaded    2
                

                等...在這種情況下,您會(huì)看到聯(lián)系人 99 和 100 都被標(biāo)記為志愿者"和已上傳"...

                etc... in this case you'll see both contact 99 and 100 are flagged as both "Volunteer" and "Uploaded"...

                我需要能夠做的是僅返回那些與通過搜索表單輸入的多個(gè)條件匹配的 contactid...contactid 必須匹配所有選擇的標(biāo)志...在我的腦海中,SQL 應(yīng)該類似于:

                What I need to be able to do is return those contactid's ONLY that match multiple criteria entered via a search form...the contactid's have to match ALL chosen flags... in my head the SQL should look something like:

                SELECT contactid 
                 WHERE flag = 'Volunteer' 
                   AND flag = 'Uploaded'...
                

                但是……什么也沒有返回……我在這里做錯(cuò)了什么?

                but... that returns nothing... What am I doing wrong here?

                推薦答案

                你可以使用 GROUP BYHAVING COUNT(*) = _:

                SELECT contact_id
                FROM your_table
                WHERE flag IN ('Volunteer', 'Uploaded', ...)
                GROUP BY contact_id
                HAVING COUNT(*) = 2 -- // must match number in the WHERE flag IN (...) list
                

                (假設(shè) contact_id, flag 是唯一的).

                (assuming contact_id, flag is unique).

                或者使用連接:

                SELECT T1.contact_id
                FROM your_table T1
                JOIN your_table T2 ON T1.contact_id = T2.contact_id AND T2.flag = 'Uploaded'
                -- // more joins if necessary
                WHERE T1.flag = 'Volunteer'
                

                如果標(biāo)志列表很長(zhǎng)并且有很多匹配項(xiàng),第一個(gè)可能會(huì)更快.如果標(biāo)志列表很短并且匹配項(xiàng)很少,您可能會(huì)發(fā)現(xiàn)第二個(gè)更快.如果性能是一個(gè)問題,請(qǐng)嘗試對(duì)您的數(shù)據(jù)進(jìn)行測(cè)試,看看哪個(gè)效果最好.

                If the list of flags is very long and there are lots of matches the first is probably faster. If the list of flags is short and there are few matches, you will probably find that the second is faster. If performance is a concern try testing both on your data to see which works best.

                這篇關(guān)于在同一列上使用多個(gè) WHERE 條件進(jìn)行選擇的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數(shù)根據(jù) N 個(gè)先前值來決定接下來的 N 個(gè)行)
                reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達(dá)式的結(jié)果;條款?)
                Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數(shù)的 ignore 選項(xiàng)是忽略整個(gè)事務(wù)還是只是有問題的行?) - IT屋-程序員軟件開發(fā)技
                Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時(shí)出錯(cuò),使用 for 循環(huán)數(shù)組)
                pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調(diào)用 o23.load 時(shí)發(fā)生錯(cuò)誤 沒有合適的驅(qū)動(dòng)程序)
                How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數(shù)據(jù)庫表作為 Spark 數(shù)據(jù)幀讀取?)
                    <tbody id='T1HZr'></tbody>
                  <tfoot id='T1HZr'></tfoot>

                    • <bdo id='T1HZr'></bdo><ul id='T1HZr'></ul>

                        <legend id='T1HZr'><style id='T1HZr'><dir id='T1HZr'><q id='T1HZr'></q></dir></style></legend>
                      • <small id='T1HZr'></small><noframes id='T1HZr'>

                          <i id='T1HZr'><tr id='T1HZr'><dt id='T1HZr'><q id='T1HZr'><span id='T1HZr'><b id='T1HZr'><form id='T1HZr'><ins id='T1HZr'></ins><ul id='T1HZr'></ul><sub id='T1HZr'></sub></form><legend id='T1HZr'></legend><bdo id='T1HZr'><pre id='T1HZr'><center id='T1HZr'></center></pre></bdo></b><th id='T1HZr'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='T1HZr'><tfoot id='T1HZr'></tfoot><dl id='T1HZr'><fieldset id='T1HZr'></fieldset></dl></div>
                        1. 主站蜘蛛池模板: 午夜精品久久久久久久久久久久久 | 亚洲一区二区久久 | 台湾佬成人网 | 日韩视频中文字幕 | 成人h视频在线观看 | 91精品国产91久久久久青草 | 成人免费黄色片 | 最近最新中文字幕 | 日韩av美女电影 | 久久久久久免费毛片精品 | 日韩免费网站 | 影音先锋中文字幕在线观看 | 最新黄色毛片 | 国产美女永久免费无遮挡 | 一区二区三区av夏目彩春 | 欧美理论片在线观看 | 国产精品免费看 | 亚洲欧美日韩精品久久亚洲区 | 国产一区二区三区在线 | 亚洲免费一区 | 欧美视频二区 | 日本天堂一区 | 一级a性色生活片久久毛片波多野 | 精品日本久久久久久久久久 | 亚洲日日夜夜 | 国产丝袜一区二区三区免费视频 | 成人深夜小视频 | 日本精品久久 | 日韩国产中文字幕 | 久久婷婷色| 久久久久国产一区二区三区四区 | 夜夜久久| www.黄色网| 国产精品视频综合 | 国产午夜精品视频 | 欧美xxxx做受欧美 | 精品久久久久久久久久久院品网 | 国产一区 | 国产小视频在线 | 91免费视频 | 国产极品车模吞精高潮呻吟 |