Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Using UNION

Status
Not open for further replies.

alehawk

Programmer
Jun 18, 2003
332
AR
Hi, i got this sqlstm
"SELECT * FROM tablaprincipal WHERE id = 1 UNION SELECT * FROM arc_org where id=2"
Error:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][Controlador ODBC Microsoft Access] El número de columnas de las dos tablas o consultas seleccionadas para una consulta de unión no coincide.

Translating:
The number of columns of the two tables or selected queries for the query of union doesnt match. (something like that)

How can I SELECT * FROM tablaprincipal WHERE id = 1 and SELECT * FROM arc_org where id=2 in one query to display data as <%=(table.Fields.Item("titulo").Value)%> ]
<%=(table.Fields.Item("nom_org").Value)%>
in my asp site?

Tnx!
 
By not doing a SELECT * but a SELECT field1, ... , fieldN

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Can I use SELECT id FROM tablaprincipal WHERE id = 1?
 
I used:
"SELECT id FROM tablaprincipal WHERE id = 1 UNION SELECT id FROM arc_org where id=2"

Error:
ADODB.Fields (0x800A0CC1)
No se encontró el elemento en la colección que corresponde con el nombre o el ordinal pedido.

THe element that corresponds to the name requested was not found :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top