Forum

Welcome to ProjeQtOr new Forum. We migrated old forum to the new website.
You will find all your posts here, with your usual account.
Just one point : you’ll have to reinitialize your password. Use “Lost password” feature.

Join between tables
 
Notifications
Clear all

Join between tables

5 Posts
2 Users
0 Reactions
3,288 Views
 imen
(@imenkolsi)
Posts: 37
Active Member
Topic starter
 
[#1051]

Hi again,
I'de like to join between n tables

I want to do with just one query that will returns all the result

For example between the table resource and the table work

i'd like to get for each resource its work

I don't want to have many queries : one to get all the resources and another query to

get the work for each one.

Would u help me ?


 
Posted : 27 Mar 2013 13H25
babynus
(@babynus)
Posts: 14956
Main Contributor Admin
 

Something like this ?

select resource.fullname, sum(work.work)
from resource, work
where resource.id=work.idResource
group by resource.fullname

 
Posted : 27 Mar 2013 13H30
 imen
(@imenkolsi)
Posts: 37
Active Member
Topic starter
 

Actually i'm looking for something like this

SELECT r.id, r.fullname, r.email, w.work
FROM resource r
LEFT JOIN WORK w ON r.id = w.idResource
GROUP BY r.name

Could u tell me how can i get this one with one from your sql methods ?

other wise, can i use directly this query on the code ? if yes would u tell me

how ?


 
Posted : 27 Mar 2013 13H39
babynus
(@babynus)
Posts: 14956
Main Contributor Admin
 
$query='SELECT r.id, r.fullname, r.email, w.work'
.' FROM resource r'
.' LEFT JOIN WORK w ON r.id = w.idResource'
.' GROUP BY r.name';
$result=Sql::query($query);

 
Posted : 27 Mar 2013 13H50
 imen
(@imenkolsi)
Posts: 37
Active Member
Topic starter
 

Thank you 🙂 every thing works really fine


 
Posted : 27 Mar 2013 14H01
Share:

Scroll to Top