SELECT to fill a field

1

Good afternoon, I have a table called Pessoa and another Matricula , I need to make a query that returns the fields name , enrollment and seq_people , where name and seq_people are in the Pessoa table and matricula in the Matricula table to return in select that each informed letter fetches in the BD passing the letters informed.

Example 1

He will make the query as he inserts the letters.

Thisselectthisasfollows,itworksforwhatitneedsinanotherfield.

SELECTseq_pessoaASid,UPPER(nome)AStextFROMpessoaWHEREnomeILIKE'%". $nome ."%'

Doubt

But now I have the following select that is not working correctly

SELECT m.matricula AS id
                 , UPPER(p.nome) AS text
              FROM matricula as m
              JOIN pessoas as p USING (seq_pessoa)

What I need is rather than enter the user name, enter the registration code and it will return the user's name.

    
asked by anonymous 07.11.2018 / 20:03

1 answer

2
SELECT m.matricula AS id
                 , UPPER(p.nome) AS text
              FROM matricula as m
              JOIN pessoas as p USING (seq_pessoa)
WHERE m.matricula = matricula

Remembering that the variable enrollment should be reported, as the variable $ name was informed in the sample code.

    
07.11.2018 / 20:12