Skip to content

How To Make A Subquery Column at Grid Data ​

Table : Products ​

Field NameData Type
idint (PK)
namevarchar(255)
descriptionvarchar(255)

Table : Favorite ​

Field NameData Type
idint(PK)
members_idint(11)
products_idint(11)

Products ​

php
$this->col[] = ["label"=>"Name","name"=>"name"];
$this->col[] = ["label"=>"Description","name"=>"description"];
$this->col[] = ["label"=>"Total Favorite","name"=>"(select count(favorite.id) from favorite where favorite.products_id = products.id) as total_favorite"];

What's Next ​

Table Of Contents ​

Released under the MIT License.