This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi All,
Im currently trying to build a plugin where i will need to build a list with data from 2 tables. from my understanding i can use union() to do this see below:
public function getPartners()
{
return \Db::table('cianhooper_mdb_partners')
->select('title', 'first_name', 'last_name', 'home_tel', 'work_tel', 'mob_tel', 'email', 'excl_tel_list')
->where('excl_tel_list', '<>', '1');
}
public function listExtendQuery($query) { $query->select('title', 'first_name', 'last_name', 'home_tel', 'work_tel', 'mob_tel', 'email', 'excl_tel_list') ->where('excl_tel_list', '<>', '1') ->union($this->getPartners()) ->get(); }
The issue im getting is:
"SQLSTATE[21000]: Cardinality violation: 1222 The used SELECT statements have a different number of columns (SQL: (select count(*) as aggregate from `cianhooper_mdb_members` where `excl_tel_list` <> 1) union (select `title`, `first_name`, `last_name`, `home_tel`, `work_tel`, `mob_tel`, `email`, `excl_tel_list` from `cianhooper_mdb_partners` where `excl_tel_list` <> 1))"
However i am selecting the same amount of columns? Any help is appreciated.
Cian
Last updated
1-2 of 2