最理想的结果结构 然后用select 来查询。不知道怎么处理 Keyword id A表title B表name ..... .....
在表A中创建name字段,把表B的name的值插入表A中,然后用语句 select title,name from A where title = 'xxxx' or name='xxxx',
select * from a, b where concat(title,name)= 'xxxx'
select * from (select id, title as keyword from A union all select id, name as keyword from B) TT where keyword = 'xxxx';
你的合并是什么意思? 是title+name='xxxx'?
也就是现在 一个搜索功能, 一个input textfield ,当用户输入一个关键词,我要查询 A表 的title 和 B表的 name, 看看有没有记录,如果有的话,就输出这个keyword。就像google那样自动提示功能(输入一个字母,然后提示,不过这个使用程序实现不用管,关键是查询)。 关键我这个自动提示功能的关键词(keyword)要查询两个表。如果在一个表,那就好办。一个select title form A 就可以了。 那提示的就是结果就是 title 一个。谢谢。
select * from ( select * from a union select * from b) where title='xxx'
B表name
.....
.....
select title,name from A where title = 'xxxx' or name='xxxx',
where concat(title,name)= 'xxxx'
是title+name='xxxx'?
一个input textfield ,当用户输入一个关键词,我要查询 A表 的title 和 B表的 name,
看看有没有记录,如果有的话,就输出这个keyword。就像google那样自动提示功能(输入一个字母,然后提示,不过这个使用程序实现不用管,关键是查询)。 关键我这个自动提示功能的关键词(keyword)要查询两个表。如果在一个表,那就好办。一个select title form A 就可以了。 那提示的就是结果就是 title 一个。谢谢。
select * from a
union
select * from b) where title='xxx'