有没有一种方法将这两个查询合并成一个?
query = "select foo from TABLE where foo like '%foo%'";
if (query.empty())
query = "select bar from TABLE where bar like '%foo%'"
更新:
select ifnull(foo,bar) from TABLE where foo like 'foo%' or bar like '%foo%';
感谢Kamal提供的想法