【问题标题】:Use And and or operator together in sqlsql中同时使用and和or运算符
【发布时间】:2021-12-31 06:22:39
【问题描述】:

有什么方法可以让我使用 and 和 like 运算符来获得期望

从表中选择 *,其中 column1 = 1 和 column2 =10,column3 像 '%we%' 或 column3 像 '%ws%'

只需要在第 3 列中使用 or ,但在其他 3 列中使用 and

【问题讨论】:

    标签: sql db2


    【解决方案1】:

    试试这个:

    Select * from table where column1 = 1 and column2 =10 and (column3 like '%we%' or column3 like '%ws%');
    

    这就是您获得所需输出的方式。

    【讨论】:

    • 我试过了,但它获取了第 1 、 2 、3 列的所有记录
    猜你喜欢
    • 1970-01-01
    • 2014-05-05
    • 1970-01-01
    • 2014-09-08
    • 1970-01-01
    • 2015-02-17
    • 1970-01-01
    • 1970-01-01
    • 2023-01-31
    相关资源
    最近更新 更多