• <tfoot id='8NJjB'></tfoot>

  • <small id='8NJjB'></small><noframes id='8NJjB'>

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

      2. 在 MySQL 中相交的替代方法

        时间:2023-08-17
      3. <i id='iFmR6'><tr id='iFmR6'><dt id='iFmR6'><q id='iFmR6'><span id='iFmR6'><b id='iFmR6'><form id='iFmR6'><ins id='iFmR6'></ins><ul id='iFmR6'></ul><sub id='iFmR6'></sub></form><legend id='iFmR6'></legend><bdo id='iFmR6'><pre id='iFmR6'><center id='iFmR6'></center></pre></bdo></b><th id='iFmR6'></th></span></q></dt></tr></i><div id='iFmR6'><tfoot id='iFmR6'></tfoot><dl id='iFmR6'><fieldset id='iFmR6'></fieldset></dl></div>
          <tbody id='iFmR6'></tbody>
      4. <small id='iFmR6'></small><noframes id='iFmR6'>

          <tfoot id='iFmR6'></tfoot>
        1. <legend id='iFmR6'><style id='iFmR6'><dir id='iFmR6'><q id='iFmR6'></q></dir></style></legend>

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

                1. 本文介绍了在 MySQL 中相交的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我需要在 MySQL 中实现以下查询.

                  I need to implement the following query in MySQL.

                  (select * from emovis_reporting where (id=3 and cut_name= '全プロセス' and cut_name='恐慌') ) 
                  intersect
                  ( select * from emovis_reporting where (id=3) and ( cut_name='全プロセス' or cut_name='恐慌') )
                  

                  我知道相交不在 MySQL 中.所以我需要另一种方式.请指导我.

                  I know that intersect is not in MySQL. So I need another way. Please guide me.

                  推荐答案

                  Microsoft SQL Server 的 INTERSECT 返回查询在 INTERSECT 操作数的左侧和右侧返回的任何不同值" 这与标准的INNER JOINWHERE EXISTS 查询.

                  Microsoft SQL Server's INTERSECT "returns any distinct values that are returned by both the query on the left and right sides of the INTERSECT operand" This is different from a standard INNER JOIN or WHERE EXISTS query.

                  SQL Server

                  CREATE TABLE table_a (
                      id INT PRIMARY KEY,
                      value VARCHAR(255)
                  );
                  
                  CREATE TABLE table_b (
                      id INT PRIMARY KEY,
                      value VARCHAR(255)
                  );
                  
                  INSERT INTO table_a VALUES (1, 'A'), (2, 'B'), (3, 'B');
                  INSERT INTO table_b VALUES (1, 'B');
                  
                  SELECT value FROM table_a
                  INTERSECT
                  SELECT value FROM table_b
                  
                  value
                  -----
                  B
                  
                  (1 rows affected)
                  

                  MySQL

                  CREATE TABLE `table_a` (
                    `id` INT NOT NULL AUTO_INCREMENT,
                    `value` varchar(255),
                    PRIMARY KEY (`id`)
                  ) ENGINE=InnoDB;
                  
                  CREATE TABLE `table_b` LIKE `table_a`;
                  
                  INSERT INTO table_a VALUES (1, 'A'), (2, 'B'), (3, 'B');
                  INSERT INTO table_b VALUES (1, 'B');
                  
                  SELECT value FROM table_a
                  INNER JOIN table_b
                  USING (value);
                  
                  +-------+
                  | value |
                  +-------+
                  | B     |
                  | B     |
                  +-------+
                  2 rows in set (0.00 sec)
                  
                  SELECT value FROM table_a
                  WHERE (value) IN
                  (SELECT value FROM table_b);
                  
                  +-------+
                  | value |
                  +-------+
                  | B     |
                  | B     |
                  +-------+
                  

                  对于这个特定问题,涉及 id 列,因此不会返回重复值,但为了完整起见,这里有一个使用 INNER JOINDISTINCT:

                  With this particular question, the id column is involved, so duplicate values will not be returned, but for the sake of completeness, here's a MySQL alternative using INNER JOIN and DISTINCT:

                  SELECT DISTINCT value FROM table_a
                  INNER JOIN table_b
                  USING (value);
                  
                  +-------+
                  | value |
                  +-------+
                  | B     |
                  +-------+
                  

                  另一个使用 WHERE ... INDISTINCT 的例子:

                  And another example using WHERE ... IN and DISTINCT:

                  SELECT DISTINCT value FROM table_a
                  WHERE (value) IN
                  (SELECT value FROM table_b);
                  
                  +-------+
                  | value |
                  +-------+
                  | B     |
                  +-------+
                  

                  这篇关于在 MySQL 中相交的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                    <tbody id='VgL83'></tbody>

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

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

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