Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Pessoal peço ajuda para relacionamento entre três tabelas que criei e não consigo acertar o relacionamento o que preciso:
As três tabelas
orcamento
detalhe_orcamento
mao_obra
No formulário insiro dados na tabela orcamento pegando dados da mao_obra e insiro na detalhe_orcamento, tudo funciona, mas na hora de mostrar os dados não consigo pegar o orcamento_id que esta na detalhe_orcamento, tendo fazer o relacionamento via phpmyadmin e da erro segue as três tabelas
-- Estrutura da tabela orcamento
--
CREATE TABLE IF NOT EXISTS `orcamento` (
`id` int(4) NOT NULL AUTO_INCREMENT,
`veiculo_id` int(4) NOT NULL,
`cliente_id` int(4) NOT NULL,
`funcio_id` int(11) NOT NULL,
`data` text NOT NULL,
`cond_pagamento` text NOT NULL,
`qtdparcelas` text NOT NULL,
`valorparcela` text NOT NULL,
`datainicio` text NOT NULL,
`datatermino` text NOT NULL,
`validadeorcamento` text NOT NULL,
`ativo` enum('0','1') NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `veiculo_id` (`veiculo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=53 ;
--
-- RELATIONS FOR TABLE orcamento:
-- veiculo_id
-- veiculos -> id
-- Estrutura da tabela detalhe_orcamento
--
CREATE TABLE IF NOT EXISTS `detalhe_orcamento` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`orcamento_id` int(11) NOT NULL,
`mao_obra_id` varchar(100) NOT NULL,
`preco` text NOT NULL,
PRIMARY KEY (`id`),
KEY `mao_obra_id` (`mao_obra_id`),
KEY `orcamento_id` (`orcamento_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=395 ;
--
-- RELATIONS FOR TABLE detalhe_orcamento:
-- mao_obra_id
-- mao_obra -> id
-- Estrutura da tabela mao_obra
--
CREATE TABLE IF NOT EXISTS `mao_obra` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`mao_obra` text NOT NULL,
`orcamento_id` int(11) NOT NULL,
`preco` text NOT NULL,
PRIMARY KEY (`id`),
KEY `orcamento_id` (`orcamento_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=18 ;Carregando comentários...