选择包含其他列的列,SQL

时间:2019-06-19 07:26:30

标签: sql oracle

我需要

SELECT * FROM MyTable WHERE Column1 LIKE Column2 

对于字符串我没有问题:

SELECT * FROM MyTable WHERE Column1 LIKE '%word%'

如何将其用于列?

让我们说Column1 = 'Hello World',而Column2 = 'Hello'

1 个答案:

答案 0 :(得分:1)

对于SQL Server,请尝试以下操作

if (digitalRead(BUTTON1) == LOW) {
    delay(500);
    i = "1";
    Serial.println(i);
  } 
  else if (digitalRead(BUTTON2) == LOW) {
    delay(500);
    j = "2";
    Serial.println(j);
  } 
  else {
    delay(500);
    x = "0";
    Serial.println(x);
  }

或使用支持大多数dbms的concat

SELECT * FROM MyTable WHERE Column1 LIKE '%'+Column2+'%' 

||在oracle和此ansi标准中用作concat

  WHERE Column1  LIKE CONCAT('%',Column2, '%')