User table
id name sex
1 john female
2 bob male
3 tom female
Schedule table
id title
2 work // bob goes to work
2 shopping
3 shopping // tom goes to shopping
1 work
Schedule.id is foreign key of User.
I wanto select rows from user table that the people who has the schedule to go shopping
2 bob male
3 tom female
How can I do like this ?
This is my cord for now, it can select rows from schedule table. but I wanto select rows from User table. I think inner join is important though,,,,,
$query = $em->createQuery(
SELECT p
FROM UserBundle:Sche p
WHERE p.title = 'shopping') ;
$result = $query->getResult();
Try this:
$query = $em->createQuery(
SELECT a.id, a.name, a.sex, b.title
FROM User a
INNER JOIN
Schedule b ON a.id = b.id
WHERE b.title = 'shopping'
);
$result = $query->getResult();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.