0
$sql = "SELECT * FROM Inscricao WHERE al_id = ".$_GET['idc'];
$sql = "SELECT * FROM Aluno WHERE al_id = ".$_GET['idc'];
$sql = "SELECT * FROM EncarregadoDeEducacao WHERE ee_id = ee_id.inscricao where al_id = ".$_GET['idc'];
tables :
CREATE TABLE IF NOT EXISTS `Inscricao` (
`insc_id` int(4) unsigned Not Null AUTO_INCREMENT,
`al_id` int(4) Not Null DEFAULT '0',
`ee_id` int(4) Not Null DEFAULT '0',
`obs_desc` varchar(250) Not Null DEFAULT 'Sem observacoes',
`prof_nome` varchar(50) Not Null DEFAULT '',
`insc_data` DATE Not Null DEFAULT '00-00-0000',
PRIMARY KEY (`insc_id`)
) ENGINE=myisam DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS `Aluno` (
`al_id` int(4) unsigned Not Null AUTO_INCREMENT,
`al_nome` varchar(50) Not Null DEFAULT '',
`al_idade` int(2) Not Null DEFAULT '0',
`al_data` DATE Not Null DEFAULT '00-00-0000',
`al_morada` varchar(80) Not Null DEFAULT '',
`al_escolaridade` int(2) Not Null DEFAULT '0',
`al_nomepai` varchar(50) Not Null DEFAULT '',
`al_nomemae` varchar(50) Not Null DEFAULT '',
`al_nomeensino` varchar(50) Not Null DEFAULT '',
`al_localensino` varchar(80) Not Null DEFAULT '',
`al_img` varchar(32) NOT NULL DEFAULT '',
`ocupacao` varchar(250) Not Null DEFAULT 'sem ocupacao de tempos livres',
`tra_simnao` varchar(250) Not Null DEFAULT 'nao',
`tra_desc` varchar(250) Not Null DEFAULT 'Sem Transporte',
PRIMARY KEY (`al_id`)
) ENGINE=myisam DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS `EncarregadoDeEducacao` (
`ee_id` int(4) unsigned Not Null AUTO_INCREMENT,
`ee_nome` varchar(50) Not Null DEFAULT '',
`ee_parentesco` varchar(10) Not Null DEFAULT '',
`ee_localtrab` varchar(80) Not Null DEFAULT '',
`ee_telemovel` int(9) Not Null DEFAULT 0,
`ee_telefone` int(9) Not Null DEFAULT 0,
`ee_urgencia` int(9) Not Null DEFAULT 0,
`ee_email` varchar(50) Not Null DEFAULT '',
PRIMARY KEY (`ee_id`)
) ENGINE=myisam DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
I need to select data from the 3 tables to list the data of the full enrollment of the student ( data from the 3 tables ) for example enrollment 1 with student 2 in charge of education5 and the respective data of each of the 3.
if you try to put in 3 select I know that from the error I wanted to know how to do what I want without error, thank you.
Helder try to provide more data to your question. How are the tables you are using? What do you need to do? So your question is not clear.
– Jorge B.
Also the last SQL string should not work like this...
– Jorge B.
The tables
Inscricao
,Aluno
andEncarregadoDeEducacao
have the same structure? At first, one can useUNION
to bring the three together darlings in one, but one would have to fill the missing columns withNULL
if the table structures are different (I don’t know if SQL does it automatically or not). P.S. Youridc
is unique among the three tables? If so, how do you guarantee it?– mgibsonbr