我有一个关于cakephp的问题$ this->查询是否可以组合三个查询并使其成为一个,?这样的例子
$this->Training->query(Select sample.* from sample where sample.name like "me")
$this->Training->query(Select sample2.* from sample2 where sample2.name like "you")
$this->Training->query(Select sample3.* from sample3 where sample3.name like "us")
这是一个搜索功能组合,2个选择框和1个文本框
答案 0 :(得分:1)
只需使用UNION子句,
$this->Training->query(Select sample.* from sample where sample.name like "me"
UNION Select sample2.* from sample2 where sample2.name like "you"
UNION Select sample3.* from sample3 where sample3.name like "us")