How do I query two tables with a column called equal?

0

What I want is that with these two tables see if in the column (which is equal in both) is equal to a request.form

For now I have this but this error marks me Ambiguous column name 'Punto_Tactico'.

set rs_pTactico = server.CreateObject("ADODB.Recordset")
sql_pTactico = "SELECT * FROM Infraestructura, Equipos WHERE 
Punto_Tactico='" & request.form("Punto_Tactico") & "'"
rs_pTactico.Open sql_pTactico,conn,3,3

I have also tried this way with inner join, here I do not have problems but it only makes the query with the infrastructure table and I want it to be in both, but I do not know how to do it

set rs_pTactico = server.CreateObject("ADODB.Recordset")
sql_pTactico = "SELECT * FROM Infraestructura INNER JOIN Equipos ON 
Infraestructura.Punto_Tactico='" & request.form("Punto_Tactico") & "'"
rs_pTactico.Open sql_pTactico,conn,3,3
    
asked by mrkillmer 14.05.2018 в 22:30
source

2 answers

0

Try this way

set rs_pTactico = server.CreateObject("ADODB.Recordset")
sql_pTactico = "SELECT * FROM Infraestructura INNER JOIN Equipos ON 
Infraestructura.Punto_Tactico=Equipos.Punto_Tactico where Equipos.Punto_Tactico ='" & request.form("Punto_Tactico") & "'"
rs_pTactico.Open sql_pTactico,conn,3,3
    
answered by 14.05.2018 / 22:56
source
0

Regardless of the rest of the query, when using JOIN instructions, in the select clause it is advisable to use the notation tabla.columna for example Infraestructura.Punto_Tactico or you can also use aliases as detailed here: link

The rest of the problems derive from you in the first case you are generating a Cartesian product of all the columns of the tables. In the second case it is possible that you have problems due to the union condition of the tables.

The most logical solution would be, knowing the structure of the tables, look for the JOIN instruction you need, the latter you can consult them here: link

    
answered by 15.05.2018 в 09:01