SELECT * 
FROM tb
WHERE ((tb.invitor_name = 'aa') and (tb.friendship_id) <> '') or ((tb.acceptor_name = 'bb') and (tb.friendship_id <> ''))

解决方案 »

  1.   

    tb.invitor_name in ('aa','bb') and tb.friendship_id!=''
      

  2.   

    SELECT * 
    FROM tb
    WHERE (invitor_name = 'aa' or acceptor_name = 'bb') and friendship_id <> ''不晓得楼主要实现什么?
    不用楼上的那和麻烦吧。这样子就可以了。
      

  3.   

    唠叨大哥,tb.invitor_name 是 'aa'
             tb.acceptor_name 是 'bb'
    还有tb.friendship_id可能有两种情况的哦!
    一种是!==,另一种是==;
    照您这个写法,(tb.invitor_name=='aa'  and (tb.friendship_id!=='')) or (tb.acceptor_name=='bb' and (tb.friendship_id ==''))
    就不行了啊!
      

  4.   

    select * from tb where
    就这段难写!
    (tb.invitor_name=='aa'  and (tb.friendship_id!=='')) or (tb.acceptor_name=='bb' and (tb.friendship_id!==''))
    不知各位看懂了吗??
    select * from tb where
    (tb.invitor_name='aa' or tb.acceptor_name='bb') and (tb.friendship_id!='')
    这样写应该是可以的了.
      

  5.   

    应该说出你想要达到的目的。
    现在大家都是从你的语句猜你的意思。你一开始写的tb.friendship_id两个都是!==,后面又说
    “还有tb.friendship_id可能有两种情况的哦!一种是!==,另一种是==;”实在搞不清楚。
      

  6.   

    在mysql的SQL语句里不存在“==”和“!==”,应该写成:“=”和“<>”。SELECT * 
    FROM tb
    WHERE (tb.invitor_name = 'aa' and tb.friendship_id) <> '') or (tb.acceptor_name = 'bb' and tb.friendship_id <> '')