I need to
select * FROM sections
id PK INT
adviserId FK-- REFERENCING `id` column ON teacher table
CREATE DEFINER=`root`@`localhost` PROCEDURE `getAllSectionsInfo`()
s.`name` AS `Section Name`,
s.`session` AS `Session`,
CONCAT(t.lastName,',',t.firstName,' ',t.middleName) AS Adviser,
s.yearLevel AS `Year Level`,
CONCAT(syStart,'-',syEnd) AS SchoolYear
FROM sections s
teacher t on s.adviserId = t.id;
Yes I also think the same, that a simple
inner join will do your job. Try the below example..
create table JTable as select T.id as Tid,T.lastName,T.firstName,T.middleName,T.isAdviser,T.status,S.id as Sid,S.name,S.adviserId from Sections as S inner join Teachers as T on T.id = S.adviserId
You can apply
left join here to make sure that you have all records of Section table either related to Teachers data or with null data.
So, now the JTable will have all the columns in that you have put on the selection list.