I have 5 tables
- college
- trade
- district
- contact
- intake
Their relationship looks like this
I'm having problem with the contact table. In this table, cid and location are the primary key. It can have only two location campus and office for each cid i.e. college id. Table intake connects college and trade table. With this query below, I'm getting results twice for each address. This is my query:
SELECT cname, ctype, tname, seats, hostel, new, dname, address, ph_no, email, website
FROM college, trade, district, intake, contact
WHERE intake.cid = college.cid and intake.tid = trade.tid and college.did = district.did and contact.cid = college.cid
ORDER BY cname ASC;
My current result:
Result that I want:
I know this can be achieved by grop_concat and concat function but I don't know how to use these functions in this situation. Somebody please help me to build the query to achieve this result.
Thank you.
new
betweenhostel
anddname
. Where is that coming from ???GROUP BY trade