PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table area ( id INTEGER, test INTEGER ); create table address ( id INTEGER, area_id INTEGER ); INSERT INTO area VALUES (1, 1),(2, 2),(3, 3),(4, 1),(5, 5),(6, 6),(7, 7), (1, 1),(2, 2),(3, 3),(4, 1),(5, 5),(6, 6); INSERT INTO area VALUES (1, 1),(2, 2),(3, 3),(4, 1),(5, 5),(6, 6),(7, 7), (1, 1),(2, 2),(3, 3),(4, 1),(5, 5),(6, 6);
Copy Clear
Copy Format Clear
<?php // Wrong case /*$res = $db::table('area AS a') ->select('a.id','a.test as code') ->groupBy('a.id') ->where('a.test', 1) ->get(); print_r($res);*/ // Wrong case $res = $db::table('area AS a') ->select('a.id','a.test','address.area_id','address.id') ->join('address', 'a.id', '=', 'address.area_id') ->groupBy('a.id','a.test') ->get(); print_r($res);
Show:  
Copy Clear