I try to get data from two connected tables.
$query="SELECT a.*, (SELECT `city_id` FROM `staff-city`) as cities FROM `staff` as a WHERE a.id=2";
i get the error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[21000]: Cardinality violation: 1242 Subquery returns more than 1 row'
It's logic, cause i have three cities for this id. The main goal is to get a row with id(2) from staff and join all data (city names) from staff-city - do it with one query and i need a final result such this:
array (
[id]=>value,
[..]=>values,
[cities]=>array(
[0]=>2,
[1]=>26
)
Thanks in advance!