Innerjoin with 3 Mysql tables

Asked

Viewed 290 times

0

I am trying to make a query that when I type the name of a product, return me the sector code and the image associated with that sector but my innerjoin is not working

I’m trying to do it like this:

select ID_CORREDOR_PC, IMAGEM_PC, produto.NOME_PRODUTO from procor 
inner join produto on produto.ID_PRODUTOS = procor.ID_PROD_PC
inner join corredor on corredor.ID_CORREDOR = procor.ID_CORREDOR_PC
WHERE produto.NOME_PRODUTO like %'vinho'

Follows tables:

Table runners

tblCorredor

Products table

inserir a descrição da imagem aqui

Procor associative table (product X corridor)

inserir a descrição da imagem aqui

I can only select by returning the runner ID according to the ID I say on the WHERE but am not able to say that my WHERE is actually the product name

  • It would be good to reduce the code to a [MCVE] can help a lot, and exchange this image stack for textual information. An example of how the result should be (with the respective input data) might help clarify which part is with the problem.

1 answer

1


Speak Lulucus, all right?

I think it’s just a syntax error of your like.

Change this like %'vinho' therefore like "%vinho"and tells the result to us.

Syntax of like

I stand by.

  • Man, it was just that problem anyway, I’ll pay more attention Thank you!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.