Access Export Union Query Error (The query cannot be completed) - ms-access

I have a database that is used to create a data file for a customer. The database has two linked tables that are linked to tables that are both in another database (but within the same database as each other). Their structure is identical.
I have a union query set up to combine both linked tables.
I am using a Macro to export that query but after running for a short while I get the error "The query cannot be completed. Either the size of the query set....."
Does Access have a limitation on union query size? Combined, the tables are a lot of data but I'm confused as both the tables I'm combining are in the same database.

It transpires that in my case I should be using Union All instead of Union as there will never be duplicates in the two tables I'm combining.
It appears that the de-duplication of the tables is what was taking up memory.

Related

JOIN tables from different dbs

I need to fix a query that used to join different tables residing in the same db. Now some of the tables were moved to a different db, while on the same server. Is there a way to modify the query to indicate where each table is?

Linqpad access tables from 2 databases in a single query

In Linqpad how can I query against two databases on one query.
I have managed to add the 2 databases like so:
https://stackoverflow.com/a/4928921/66975
so the connection says "db1 + db2".
However I am unsure how to access the tables from db2 to make queries.
I can query against tables in the first db.
Note: both dbs contain more or less the same table names.

how to select from one database using codition in another

I am trying to select from one database using condition in another but my problem is how to do this in my editor i used this code in my phpmyadmin environment and it work fine, but how will write same query in my source code,my problem here is how to connect to two different db in one statement
select * from users.message where sender in( select id from secured.reg_users)
As long as the 2 databases are in the same mysql server, the above query will work with a single connection. (Remember, phpmyadmin will connect to a single database as well at any point of time!) If not, then you can experiment with federated tables, but most likely you will not be able to do this in sql only.
In the latter case, your code needs to retrieve the list of ids from the secured.reg_users table, then use that list as parameter to the main query.

selecting multiple tables in mysql and combine the results [duplicate]

The table names in my mysql database are dynamically generated. Is there some way to select data from tables which have a name matching a pattern? I guess it will look like:
select * from 'table_id_%'
No, you can't do that with MySQL. Tables in a query can't be dynamically specified - you have to build the list in your application (or do several single-table queries).
You can use INFORMATION_SCHEMA TABLES table to find tables you want, here is documentation: http://dev.mysql.com/doc/refman/5.0/en/tables-table.html . TABLES table has column NAME which represents names of tables. After finding table names you can run any sql queries you like.
That's not possible in the way you'd like to do it. However you could probably use prepared statements which are basically query-templates where you specificy the parameters (AFAIK also table names) that get replaced depending on your needs without copy and pasting the same query over and over again for different tables.

Access Passthrough Query from SQL Server 2005

I have created a passthrough query from an sql server database to display data into an access database. What i am wanting now is for this information to then update another table. which has other information on it other information on it imported from another passthrough query.
Think of your passthroughs as read only queries. You will not be able to do any record manipulation - only return data.
You would want a separate query that does your updates. You may even have to write the resulting dataset from the passthrough to a temp table and use that in your update query.
In a simplified explanation of passthroughs, imagine I have two linked tables with 10000 records each and I link them for a query that returns 5 records. Access needs to pull 20000 records (all from each table) across the network in order to compare them and give you 5 results. In a passthrough, it does the comparison on the other end and only brings 5 records across.