你好我在数据库中有2对多关系并且使用sql查询是可以但是不能将查询mysql转换为dql或querybuilder请帮帮我
SELECT *
FROM `resturant`
LEFT JOIN `food`
ON `resturant`.`id` = `food`.`resturant_id`
WHERE `food`.`name`LIKE "%pizza%"
GROUP BY `resturant`.`name`
答案 0 :(得分:0)
假设您的Restaurant
实体通过属性Food
与$foods
实体相关联:
$this->createQueryBuilder('restaurant')
->leftJoin('restaurant.foods', 'food')
->where('food.name LIKE %pizza%')
->groupBy('restaurant.name')
->getQuery()->getResult();