It’s not necessarily true that we don’t pass parameters to a view. It is quite true that we can not define parameters (well, at least in my experiences did not happen). But who said we need?
Watch the view, with some joins:
CREATE
VIEW `view_ranking_candidato` AS
SELECT
`candidato`.`nick` AS `nick`,
`candidato`.`nomeCompleto` AS `nomeCompleto`,
SUM(`desafios`.`pontuacao`) AS `totalPontos`
FROM
(((`acertoCandidato`
JOIN `respostaSubmetida` ON ((`respostaSubmetida`.`idRespSubmetida` = `acertoCandidato`.`idRespostaSubmetida`)))
JOIN `desafios` ON ((`desafios`.`idDesafio` = `acertoCandidato`.`idDesafio`)))
JOIN `candidato` ON ((`candidato`.`idCandidato` = `respostaSubmetida`.`idCandidato`)))
GROUP BY `candidato`.`idCandidato`
If you want to do a parameterized search, just include the Where clause in the select that will consume the view:
select * from view_ranking_candidato ---> vai executar a view sem parâmetros
select * from view_ranking_candidato Where nick='tester' ---> vai executar a view incluindo a cláusula where.
Adapted from:
http://profvictorhugo.esy.es/bd/mysql/mysql-view-tutorial/
At least cite the important parts here, and not a link-only response.
– UzumakiArtanis
Nice of you to answer the question, but the way it looks spam. What do you think of [Edit] rewriting the answer can put the relevant parts of your post in it and leave the link as an add-on. When you have time I recommend reading: We want answers that contain only links?
– rray
Right, guys. I changed!
– Victor Hugo Lopes
I believe that the edition of the original LINQ response made it clearer now, at the point where I tried to contribute.
– Victor Hugo Lopes