April 24, 2024, 11:48:33 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Microsoft Access - too much fields, error HY001

Started by JoaoAfonso, January 07, 2008, 05:04:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JoaoAfonso

Ahoy.

I am working with DB and SELECTs, and using the following sentence it returned an error:

SELECT * FROM table1 WHERE nome='Joao' UNION ALL SELECT * FROM table1 WHERE nome='Antonio' UNION ALL SELECT * FROM table1 WHERE nome='Fernando'

ERRORTEXT - [Microsoft][ODBC Microsoft Access Controler] Too much fields defined
ERRORCODE - HY001


I believe this is strange, because table1 has like 25 columns and 5 rows up to now. In my point of view, it is too few UNION ALL to give any kind of error (all in all, I am still testing things, but when using it in a program, I would expect many more UNION ALL). Forgot to say that using just one UNION ALL it worked perfectly as supposed:

SELECT * FROM table1 WHERE nome='Joao' UNION ALL SELECT * FROM table1 WHERE nome='Antonio'

Am I doing anything wrong?

On the other hand, executing a single select with 30 UNION ALL is faster or is the same of executing 30 individual selects?

Thank you in advance for any explanations
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900

billhsln

Replace your select with:


SELECT * FROM table1 WHERE nome IN ('Joao','Antonio','Fernando')

This will give you the result you are looking for.

Bill
When all else fails, get a bigger hammer.

JoaoAfonso

Wonderful! I was after that keyword conjunction for some days. I understand now that UNION and UNION ALL are only to be used if the intention is join results of different tables. Thank you very much!
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900