你的SQL没有对两个表建立关系呀,,比如
sql ="select unit.id,fruit.id,unit.name,fruit.name,unit.date,fruit.date from unit,fruit where (unit.name like '%"+key+"%' or fruit.name like '%"+key+"%') and unit.id=fruit.id order by fruit.date desc";
sql ="select unit.id,fruit.id,unit.name,fruit.name,unit.date,fruit.date from unit,fruit where (unit.name like '%"+key+"%' or fruit.name like '%"+key+"%') and unit.id=fruit.id order by fruit.date desc";
两张表的name字段记录并不是一样的,两张表没有任何联系。
是不是非要建立联系,才能进行搜索呢?
union
select * from unit where unit.name like '%condition%'