Reputation: 3
(Using mysql in php)
Hi people i cant seem to find the answer through google or on this site so help is much appreciated. I'm trying to join 2 tables together displaying JUST the name of students, then to order it alphabetically which i havent gotten into yet help on how to do that is also appreciated :D. All info needed is here
the id is set to INT NOT NULL AUTO_INCREMENT
and is the PRIMARY KEY
the StudentID is set to INT
the Name is set to VARCHAR(30)
and the age is set to an INT
as well.
My question is, why is the following php script not displaying any results? besides the table? I am using wamp.
Upvotes: 0
Views: 36
Reputation: 30809
You need to UNION
both the results and apply ORDER
on it, e.g.:
SELECT Name
FROM(
SELECT Name
FROM Group1
UNION
SELECT Name
FROM Group 2
) a
ORDER BY a.Name;
Upvotes: 1