Search with Inner John

Asked

Viewed 95 times

0

I am doing a search where the user enters with the order ID and the system does return the request notice, products code and Qtd. And these data are arranged in 2 tables. (I did not create the database, it already came ready) However, with my query using innerjoin the console says that the search is ambiguous. tb_ped_sell is where the quantity and product id is tb_request for sale is where the order comments are.

SELECT TB_PED_VENDA_ITEM.ID_IDENTIFICADOR,
TB_PED_VENDA_ITEM.QTD_ITEM,TB_PEDIDO_VENDA.OBSERVACAO 
FROM TB_PED_VENDA_ITEM INNER JOIN TB_PEDIDO_VENDA
ON TB_PED_VENDA_ITEM.ID_PEDIDO = TB_PEDIDO_VENDA.ID_PEDIDO
WHERE ID_PEDIDO=$id"

2 answers

4

Missing specify the table.

WHERE TB_PED_VENDA_ITEM.ID_PEDIDO=$id"
      ^^^^^^^^^^^^^^^^^

Like ID_PEDIDO is a column present in more than one of them, the Planner needs to know which one you are referring to.

The fact that both are equal in their specific case is "mere coincidence". (Okay, actually I could deduce programmatically, but it doesn’t make sense to add this complexity to the query Planner just so the programmer doesn’t do his part).

  • Thanks! I got it, haha

2


The database returns the ambiguous message when you have a field is in more than one select table, in this case it is probably the ID_PEDIDO of the Where clause.

Try to put the table name in front:

where B_PED_VENDA_ITEM.ID_PEDIDO=$id
  • Solved the problem, but is not displaying to the field notice of the requested table

  • Sorry, the mistake was in my bank. the OBS field is like a type q n know. BLOB. I tried another field and gave, sorry. And thank you!

  • Dispose, we are there to help.

Browser other questions tagged

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