用循环慢慢写: 获取所有表名: select name from sysobjects where type='U'
获取所有字段名: Select Name from SysColumns Where id=Object_Id('TableName')
我想你会懂
2026-01-06 11:12:46
只有用动态sql 来做,最好结合存贮过程
关于表,字段的信息都可以从系统的一些表来取得 比如sql server -> systables , syscolumns 其他也大致一样。
第一层游标循环 -> 表 第二层游标循环 -> 字段
拼出动态sql => select * from table_name where field1 like '%keyword%' or field2 like '%keyword%' or field3 like '%keyword%' ...
插入临时表
循环完毕 取得所有的结果。
二到无穷大
2026-05-14 21:16:27
select a from 1 where a='word' union all select b from 1 where b='word' union all select c from 2 where c='word' union all select d from 3 where d='word' union all select e from 3 where e='word' union all select f from 3 where f='word'
听一首歌流一夜泪
2026-01-26 05:54:15
是在不知道你要怎么省略 select * from 表名 where 字段=“word” 我觉得只能这样了,不管是10个表还是100个表,查询语句只能这样写吧,呵呵,不过我还是个新手,要有好的办法也未尝可知,希望有帮助