一个表包含两列a和b如果col a = col b,则它将打印第一个值,否则将打印两个值

时间:2018-06-22 06:20:55

标签: mysql mysqli

一个表包含两列a和b 如果col a = col b,则它将打印第一个值,否则将打印两个值。

     a    b
------------------------------------------

    100  100        
    101  102
    103  105    
    102  102

需要放出

    100
    101  102
    103  105
    102     

2 个答案:

答案 0 :(得分:2)

select a, 
       case when a = b  
            then null 
            else b 
       end as b
from your_table

答案 1 :(得分:2)

您可以使用此查询

public static WebElement getObject( String locator, String identifier) 
{
    element = null;
    if(driver!=null) {
        System.out.println("driver is not null");
    if(locator.equalsIgnoreCase("xpath"))
    {
        element = driver.findElement(By.xpath(identifier));
        System.out.println("Loop entered");
        return element;
    }
    else if(locator.equalsIgnoreCase("id"))
    {
        element = driver.findElement(By.id(identifier));
    }
    else if(locator.equalsIgnoreCase("name"))
    {
        element = driver.findElement(By.name(identifier));                  
    }
    else if(locator.equalsIgnoreCase("tagName"))
    {
        element = driver.findElement(By.tagName(identifier));   
    }
    else if(locator.equalsIgnoreCase("linkText"))
    {
        element = driver.findElement(By.linkText(identifier));  
    }
    else if(locator.equalsIgnoreCase("partialLinkText"))
    {
        element = driver.findElement(By.partialLinkText(identifier));   
    }
    else if(locator.equalsIgnoreCase("className"))
    {
        element = driver.findElement(By.className(identifier)); 
    }
    else if(locator.equalsIgnoreCase("cssSelector"))
    {
        element = driver.findElement(By.cssSelector(identifier));   
    } else {
        System.out.println("Invalid details given for searching Webelement");               
    }

} else {
    System.out.println("Invalid details given for searching Webelement");
}
    return element;
}