各位高手大大,下面是我的sql語句,可是執行起來得不到預期的結果,該如何寫呢
--------------------------------------
select a.libuser_id,a.userid,a.username,a.email,a.inner_phone,b.dept_name from libuser a,department b
where a.department_id *= b.department_id and a.active= 'P '
and (a.userid like '%abc% ' or a.username like '%abc% ' or b.dept_name like '%abc% ')
order by a.department_id,a.userid
我去掉 b.dept_name like '%abc% ' 後運行正常,加上就搜索出全部了,這是怎麼回事情呢
求高手幫忙寫寫sql語句,謝謝。
------解决方案--------------------
select a.*,b.* from libuser a inner join department b on a.department_id = b.department_id and a.active= 'P '
and (a.userid like '%abc% ' or a.username like '%abc% ' or b.dept_name like '%abc% ')
order by a.department_id,a.userid
------解决方案--------------------
a.department_id *= b.department_id 什么意思?
楼主要搜索什么内容需要说下吧
很多表,内容不同,有特性的
还有这个问题SQL论坛比较适合哦