Last active
March 8, 2017 23:00
-
-
Save antunesleo/4e00a92874ee060f52fea9b8e2d5b645 to your computer and use it in GitHub Desktop.
Arquivo contendo diversas queries de reconhecimento e exportação do banco de dados do projeto Nutrimep.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Seleciona o Alimento fazendo o join das tabelas com relacionamento | |
SELECT | |
a.*, | |
ga.nome AS grupo_alimentar_nome, | |
ta.nome AS tabela_alimentar_nome | |
FROM | |
alimento AS a | |
JOIN grupo_alimentar AS ga ON a.grupo_alimentar_id = ga.id | |
JOIN tabela_alimentar AS ta ON a.tabela_alimentar_id = ta.id | |
-- Seleciona a tabela alimento_nutriente fazendo os joins com as tabelas referênciadas | |
SELECT | |
an.*, | |
a.nome AS alimento_nome, | |
n.nome AS nutriente_nome | |
FROM | |
alimento_nutriente AS an | |
JOIN alimento AS a ON an.alimento_id = a.id | |
JOIN nutriente AS n ON an.nutriente_id = n.id | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment