简体   繁体   中英

how to use clause (where,and not ,or not) sql

How to use clause (where,and not,or not) if I have condition like this

  • where table1.coloumn1='m'
  • where table1.coloumn2 <>(not equal) table2.coloumn.2
  • where table1.coloumn3<> (not equal)table2.coloumn3

I want to show table1.coloumn1='m' and ( table1.colomn2-table2.coloumn2 and table1.coloumn3-table2.coloumn ) if they are not have values same. Is use and, not , combine or,and?

Just write

select table1.*, table2.*
    from table1
    join table2 on table1.coloumn1='m' and table1.coloumn2<>table2.coloumn2 and table1.coloumn3 <> table2.coloumn3

As you did not write very clearly how you want to combine those conditions with the :

SELECT * 
FROM table1, table2 
WHERE table1.column1='m' 
  AND  NOT table1.column2 != table2.column2 
   OR  NOT table1.column3 != table2.column3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM