两张表的模糊查询 我有两张表a和b,a表有字段Col1,b表有字段Col2。Col1中放的是一些文本内容。Col2中放的是一些关键字。请问如何把a表Col1中含有Col2关键字的记录查出来。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一些关键字就是一些特定的词组,Col2列中一行存放一个关键字 例如如a表Col1为:sssgoodsdcdflowerdgggpipoocsdnsgsb表Col2为:goodcsdnfine我想要的查询结果根据b表查a表,得出:sssgoodsdpipoocsdnsgs因为Col1中的这两条记录包含有Col2中good和csdn这两个词。 create table t1(Col1 nvarchar(100))insert into t1 select 'sssgoodsd'insert into t1 select 'cdflowerdggg'insert into t1 select 'pipoocsdnsgs'create table t2(Col2 nvarchar(20))insert into t2 select 'good'insert into t2 select 'csdn'insert into t2 select 'fine'goselect * from t2 inner join t1 on CHARINDEX(t2.col2,t1.col1)>0/*Col2 Col1-------------------- ----------------------------------------------------------------------------------------------------good sssgoodsdcsdn pipoocsdnsgs(2 行受影响)*/godrop table t1,t2 如何将表中数据复制到另一个表 ms server 2005 创建数据库 谁能给个在MS SQLServer里计算日期的例子 两个小问题请大家帮忙?多谢多谢 约束为何不起作用?? sql server2000中的数据库复制问题 SQL 求两个表的合集(测试数据已构建) 执行exec sp_spaceused 时出现unallocated space为负数!!! 我的windows 2000不能通过TCP/IP来连接NT上的SQL Server 6.5 多个视图加别名,怎么和单个视图不一样??? 数据表数据全没了,急! sql语句 两个表数据根据条件合并
sssgoodsd
cdflowerdggg
pipoocsdnsgsb表Col2为:
good
csdn
fine我想要的查询结果根据b表查a表,得出:
sssgoodsd
pipoocsdnsgs因为Col1中的这两条记录包含有Col2中
good和csdn这两个词。
insert into t1 select 'sssgoodsd'
insert into t1 select 'cdflowerdggg'
insert into t1 select 'pipoocsdnsgs'
create table t2(Col2 nvarchar(20))
insert into t2 select 'good'
insert into t2 select 'csdn'
insert into t2 select 'fine'
go
select * from t2 inner join t1 on CHARINDEX(t2.col2,t1.col1)>0
/*
Col2 Col1
-------------------- ----------------------------------------------------------------------------------------------------
good sssgoodsd
csdn pipoocsdnsgs(2 行受影响)*/
go
drop table t1,t2