Linqpad access tables from 2 databases in a single query - linq-to-sql

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.

Related

SELECT INTO Oracle SQL table from MySQL table with SQL Developer

Getting ready to get rid of a MySQL database and switch to Oracle SQL. I am using Oracle SQL Developer. Need to get the records from a MySQL table and populate its corresponding table in SQL.
I was able to establish a Database connection in SQL Developer to the MySQL database. I checked the connection by doing a simple SELECT * from the table to make sure it returned all the records.
However, the new Oracle SQL table has quite a few changes - the names in the MySQL table all had a "tn" prefix, ie tnStore, tnConfigDate, etc. The SQL table gets rid of that prefix. That is issue #1.
There will also be several new columns in the new table. That data will be added later from elsewhere. And the data will not be in the same order as the MySQL table.
How do a write up a SELECT INTO statement in SQL Developer to populate the SQL table with the data from the MySQL table and correlate the corresponding columns while leaving new fields blank for now?
Here is a way by programming but not sure how to make it in single query:
I hope we need to use data dictionary tables in oracle all_tab_columns and I am not sure in Mysql ( like similar table)
Get the column name from Mysql table by taking out prefix "tn" and
compare the column name with SQL table. (possible use an cusrsor)
If matched build SQL statement for SELECT INTO statement and blank
for new fields possibly in a loop.
Once done for all columns , execute that statement
Consider migrating the existing MySQL tables as-is straight to Oracle using SQL Developer. Then move/refactor the data around to your new-tables with desired column definitions using INSERT as SELECTs.
Could be considerably faster, plus once the 'raw' data is there, you can do your work over and over again, until you get it just right.
Note you can also simply drag-and-drop to move a MySQL table from it's connection to an existing Oracle database connection to move the table over (DDL, Data, or Both).

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?

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.

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

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.

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.