Select rows with the same value in multiple columnsAre two indexes needed?Finding rows for a specified date...

Has the laser at Magurele, Romania reached a tenth of the Sun's power?

El Dorado Word Puzzle II: Videogame Edition

Is there a reason to prefer HFS+ over APFS for disk images in High Sierra and/or Mojave?

How to leave product feedback on macOS?

How to get directions in deep space?

How to test the sharpness of a knife?

Animation: customize bounce interpolation

What is the meaning of "You've never met a graph you didn't like?"

How to write Quadratic equation with negative coefficient

Echo with obfuscation

How to make a list of partial sums using forEach

Why does the Persian emissary display a string of crowned skulls?

What the heck is gets(stdin) on site coderbyte?

Anime with legendary swords made from talismans and a man who could change them with a shattered body

What is this high flying aircraft over Pennsylvania?

Why do Radio Buttons not fill the entire outer circle?

Showing mass murder in a kid's book

Why would five hundred and five be same as one?

Should I warn a new PhD Student?

Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?

Limit max CPU usage SQL SERVER with WSRM

What should be the ideal length of sentences in a blog post for ease of reading?

Alignment of six matrices

Does Doodling or Improvising on the Piano Have Any Benefits?



Select rows with the same value in multiple columns


Are two indexes needed?Finding rows for a specified date rangeAdding index to large mysql tables#1093 - You can't specify target table 'R' for update in FROM clauseGet a user's rank from an equation, and then store it in the tableOptimizing a simple query on a large tableHow to improve query count execution with mySql replicate?MySQL query taking too longselect MAX() from MySQL view (2x INNER JOIN) is slowWhy does the Select statement stalls when executed directly in sequence?













0















I have created this table:



CREATE TABLE IF NOT EXISTS `names` (
`ID` int(6) unsigned NOT NULL,
`C1` varchar(200),
`C2` varchar(200),
`C3` varchar(200),
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
INSERT INTO `names` (`ID`, `C1`, `C2`, `C3`) VALUES
('1', 'Richard', 'Ken', 'Dan'),
('2', NULL,'Richard', 'Helen'),
('3', 'Ken', NULL, 'Maria');


I can select rows that contain "Ken" with an OR:



SELECT *
FROM `names`
WHERE C1 = 'Ken' or C2 = 'Ken' or C3 = 'Ken'


But, I need to select the rows which have “Ken” in one of the columns C1, C2, or C3, but without using OR.









share







New contributor




Radu Turcan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    I have created this table:



    CREATE TABLE IF NOT EXISTS `names` (
    `ID` int(6) unsigned NOT NULL,
    `C1` varchar(200),
    `C2` varchar(200),
    `C3` varchar(200),
    PRIMARY KEY (`id`)
    ) DEFAULT CHARSET=utf8;
    INSERT INTO `names` (`ID`, `C1`, `C2`, `C3`) VALUES
    ('1', 'Richard', 'Ken', 'Dan'),
    ('2', NULL,'Richard', 'Helen'),
    ('3', 'Ken', NULL, 'Maria');


    I can select rows that contain "Ken" with an OR:



    SELECT *
    FROM `names`
    WHERE C1 = 'Ken' or C2 = 'Ken' or C3 = 'Ken'


    But, I need to select the rows which have “Ken” in one of the columns C1, C2, or C3, but without using OR.









    share







    New contributor




    Radu Turcan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I have created this table:



      CREATE TABLE IF NOT EXISTS `names` (
      `ID` int(6) unsigned NOT NULL,
      `C1` varchar(200),
      `C2` varchar(200),
      `C3` varchar(200),
      PRIMARY KEY (`id`)
      ) DEFAULT CHARSET=utf8;
      INSERT INTO `names` (`ID`, `C1`, `C2`, `C3`) VALUES
      ('1', 'Richard', 'Ken', 'Dan'),
      ('2', NULL,'Richard', 'Helen'),
      ('3', 'Ken', NULL, 'Maria');


      I can select rows that contain "Ken" with an OR:



      SELECT *
      FROM `names`
      WHERE C1 = 'Ken' or C2 = 'Ken' or C3 = 'Ken'


      But, I need to select the rows which have “Ken” in one of the columns C1, C2, or C3, but without using OR.









      share







      New contributor




      Radu Turcan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I have created this table:



      CREATE TABLE IF NOT EXISTS `names` (
      `ID` int(6) unsigned NOT NULL,
      `C1` varchar(200),
      `C2` varchar(200),
      `C3` varchar(200),
      PRIMARY KEY (`id`)
      ) DEFAULT CHARSET=utf8;
      INSERT INTO `names` (`ID`, `C1`, `C2`, `C3`) VALUES
      ('1', 'Richard', 'Ken', 'Dan'),
      ('2', NULL,'Richard', 'Helen'),
      ('3', 'Ken', NULL, 'Maria');


      I can select rows that contain "Ken" with an OR:



      SELECT *
      FROM `names`
      WHERE C1 = 'Ken' or C2 = 'Ken' or C3 = 'Ken'


      But, I need to select the rows which have “Ken” in one of the columns C1, C2, or C3, but without using OR.







      mysql





      share







      New contributor




      Radu Turcan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Radu Turcan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Radu Turcan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 6 mins ago









      Radu TurcanRadu Turcan

      11




      11




      New contributor




      Radu Turcan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Radu Turcan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Radu Turcan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Radu Turcan is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f232674%2fselect-rows-with-the-same-value-in-multiple-columns%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Radu Turcan is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Radu Turcan is a new contributor. Be nice, and check out our Code of Conduct.













          Radu Turcan is a new contributor. Be nice, and check out our Code of Conduct.












          Radu Turcan is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f232674%2fselect-rows-with-the-same-value-in-multiple-columns%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          ORA-01691 (unable to extend lob segment) even though my tablespace has AUTOEXTEND onORA-01692: unable to...

          Always On Availability groups resolving state after failover - Remote harden of transaction...

          Circunscripción electoral de Guipúzcoa Referencias Menú de navegaciónLas claves del sistema electoral en...