I've got 2 SQL tables: NAMES and RELATIONSHIPS Currently NAMES just has 2 columns: name and name_id. The other is a list of relationships between people in the NAMES table. It has 3 columns: primaryperson_id, relatedperson_id, and relationship_id. The primaryperson_id and related_person_id are name_ids from the NAMES table. Each person in NAMES can have multiple entries in either the primary or related columns of RELATIONSHIPS (is that a many-to-many relationship?).
This query works:
SELECT people.name AS 'primary', relationships.related_person_id AS relatedto
FROM relationships
JOIN people
ON people.name_id=relationships.primary_person_id
ORDER BY people.name_id;
But I'd like to show a name (i.e. text) in the relatedto column rather than the id number. How can I do that?
relationships.related_person_id AS relatedtotor.related_person_id AS relatedtobut otherwise it worked! Thanks. – WebUserLearner Jun 26 '18 at 02:03