我不回写啊,朋友 据个例子 A表keyboard bbc bdd B表 keyboard atr bcc批评'b'子串 查询结果应该是这样 bbc bcc bdd (如果可以实现,那么后面的子串也应该实现从小到大的匹配)谢谢
问题说明越详细,回答也会越准确!参见如何提问。(提问的智慧)select * from A where column like '%b%' union all select * from B where column like '%b%'
TRY: 假设 F1中的内容为keyboard SELECT * FOM ( SELECT * FOM A UNION ALL SELECT * FOM B) A where LENgth(F1)-length(replace(f1,'b',''))>0 order by LENgth(F1)-length(replace(f1,'b','')) desc,replace(f1,'b','')
select * from ( select * from A where column like '%b%' union all select * from B where column like '%b%' ) t order by LENGTH(column)-LENGTH(replace(column,'b','')) desc
select title from ( select title from {$dbtbpre}ecms_all where title like '%{$keyboard}%' union all select title from {$dbtbpre}ecms_mtv where title like '%{$keyboard}%' ) t order by LENGTH(title)-LENGTH(replace(title,'{$keyboard}','')) desc可是提示我 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #12' at line 1<br>Resource id #12请问这个是什么错误
据个例子
A表keyboard
bbc
bdd
B表
keyboard
atr
bcc批评'b'子串
查询结果应该是这样
bbc
bcc
bdd
(如果可以实现,那么后面的子串也应该实现从小到大的匹配)谢谢
from A
where column like '%b%'
union all
select *
from B
where column like '%b%'
假设 F1中的内容为keyboard
SELECT *
FOM (
SELECT * FOM A
UNION ALL
SELECT * FOM B) A
where LENgth(F1)-length(replace(f1,'b',''))>0
order by LENgth(F1)-length(replace(f1,'b','')) desc,replace(f1,'b','')
select *
from (
select * from A where column like '%b%'
union all
select * from B where column like '%b%'
) t
order by LENGTH(column)-LENGTH(replace(column,'b','')) desc
select title from {$dbtbpre}ecms_all where title like '%{$keyboard}%'
union all
select title from {$dbtbpre}ecms_mtv where title like '%{$keyboard}%'
) t
order by LENGTH(title)-LENGTH(replace(title,'{$keyboard}','')) desc可是提示我
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'Resource id #12' at line 1<br>Resource id #12请问这个是什么错误