phpcms系统,在多个表格中搜索多个字段的sql语句?

我用的是phpcms做的站,

我想在后台同时搜索出 表phpcms_content 中 字段title 或 表phpcms_c_news 中 字段name 包含关键词为 123 的所有文章。

请问后台搜索怎么改

或者单单就我的描述例句来说,sql查询语句是怎样写的?

请求大侠帮忙。

第1个回答  2010-01-06
select title from phpcms_content
union all
select name from phpcms_c_news where name like '%123%'

结果是把title和name 放一张表中
第2个回答  2010-01-06
用表的关联来实现,你可以参考下
select title from phpcms_content where title like '%123%' union all
select name from phpcms_c_news where name like '%123%'
第3个回答  2010-01-06
select * from (
select title t_name from phpcms_content
union all
select name t_name from phpcms_c_news

)
where t_name like '%123%'本回答被提问者采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网