救命啊,请教如何在全文检索时候搜索多个表中的多个字段

coolfatfish 2003-08-21 11:40:50
我已经看过很多例子了
但是全文检索都是只能检索一张表的
请问如何能同时检索多张表呢

小弟是菜鸟 在实习
今天公司里要我完成此功能
请各位大虾救我啊
...全文
72 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
coolfatfish 2003-08-21
  • 打赏
  • 举报
回复
每个表都有一个相同的字段id啊 ,它是最后通过比方说
titles.id=info.id返回回来啊
coolfatfish 2003-08-21
  • 打赏
  • 举报
回复
运行结果出来只有前面那个select 才有效的
lifeforu 2003-08-21
  • 打赏
  • 举报
回复
表结构不一样你不想想结果会怎么返回来
如果想一次搞好就要求结构一样,表个数不是问题用union连接就可以拉
lifeforu 2003-08-21
  • 打赏
  • 举报
回复
表结构不一样的话你的想怎么办?
就按你的select * from titles,info
where freetext(*,'li')
你也不想想结果怎么返回来????
表的个数不是问题,用union连接起来就可以拉
coolfatfish 2003-08-21
  • 打赏
  • 举报
回复
不行的吧
我的表结构是不同的
而且是很多个表呢
coolfatfish 2003-08-21
  • 打赏
  • 举报
回复
表结构是不一样的
pengdali 2003-08-21
  • 打赏
  • 举报
回复
select * from titles where freetext(*,'li')
union all
select * from info where freetext(*,'li')
hxy2003 2003-08-21
  • 打赏
  • 举报
回复
UP
lifeforu 2003-08-21
  • 打赏
  • 举报
回复
select * from titles where freetext(*,'li')
union select * from info where freetext(*,'li')
不过表结构要一致

coolfatfish 2003-08-21
  • 打赏
  • 举报
回复
比方说
我写入
select * from titles,info
where freetext(*,'li')
这样的出错结果是说freetext只能检索一张表的
好郁闷啊
lifeforu 2003-08-21
  • 打赏
  • 举报
回复
select id,'table'='titles' from titles where freetext(name ,'23')
union
select id,'table'='info' from info where freetext(address ,'23')

我这里的意思是把表名显示出来,以免不知道ID是哪个表里的
coolfatfish 2003-08-21
  • 打赏
  • 举报
回复
自己up
coolfatfish 2003-08-21
  • 打赏
  • 举报
回复
lifeforu(苍白到底) 你的方法不行的



Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'table'.
Server: Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'table'.
lifeforu 2003-08-21
  • 打赏
  • 举报
回复
select id,table='titles' from titles where freetext(name ,'23')
union
select id,table='info' from info where freetext(address ,'23')

这样试试?
dreamboy527 2003-08-21
  • 打赏
  • 举报
回复
select a.[column1],a.[column2],a.[column3],b.[column],c.[column],d.[column]
form table1 a,
(select [column] from table2 where [column](*,'li')) b,
(select [column] from table3 where [column](*,'li')) c,
(select [column] from table4 where [column](*,'li')) d,
order by a.id
CrazyFor 2003-08-21
  • 打赏
  • 举报
回复
那用JOIN.
coolfatfish 2003-08-21
  • 打赏
  • 举报
回复
举个例子
比方两个表
表一titles 它一共3个字段 id name age
另一个表info 它两个字段 id address
我现在要查找字段 name 和 address中包含“23"这个词的
返回的是id
那应该如何做啊

22,207

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧