Multi column joins and Federated Tables - mysql

I am having a problem with getting information from two tables in our databases.
Table A is a federated table from our accounts server which works perfectly well if queried on its own. It has no unique ID field, but Job and Code fields are unique
Table B is an analogue to Table A on our Production server and has Job and Code fields that should match those in the Accounts server.
I would like to create a query that gives me all the Codes in table A that do no exist in table B for a given Job.
When I try and perform any query that links Table A and Table B directly I get Connection Errors - is this something that is outside the scope of Federated Tables?

Related

Join local table with linked table

I have a help desk system that uses a MySQL database and I've linked to some of its tables from Access 2016. I also created a local table in the Access DB that contains some fields for management to add info such as comments, priority, target date and a few others and linked it to the main 'ticket' table's ID I brought in from MySQL. What I'd like to do is pull in the ticket data (read-only) and display it on a form with my local table data (writable) so management can track the status of the tickets. Here's the property sheet of the query:
Record Locks = Edited Record
Recordset Type = Dynaset (Inconsistent Updates)
So, the linked table 'Tickets' is left joined to my comments table (comments table has tickets' ID). When I run the query (which includes fields from both the local and linked tables) I can add info into the fields from the local table, and a record is created in that local table but the ID from the linked table (tickets) is not written to the local table (comments) although a sub record is created (the record in the local table has a 'plus' sing that opens what I assume is the record from the MySQL DB.
I tried using a one-to-one relationship (which is the most there should ever be) but I don't get anything because the local table doesn't have any records yet.
Hopefully I'm overlooking something simple..

MySql - Can I add a label to a table and retrieve using sql query

I have a requirement to provide a REST endpoint to create/delete tables for a privileged user.
When user makes a request to create table 'xyz', I create table with prefix "user_" and return response saying
'user_xyz' is created.
This way I know what tables are candidates for deletion when a request is made.
But I wish to create table "xyz" as requested by user and would like to add some label like "deletable" so that I can
query to find if a table can be deleted.
One option is adding a comment for table and but I have to query information_schema. Comment does not sound very correct.
Can this problem be solved using any other approach when I use MySql database.
I don't think you have much other options other than the one you suggest,
prefixing/suffixing table name
use table comment
create meta table with UserId(has the advantage of foreign keys)
and TableName fields (has the disadvantage of integrating the table
name with the actual very table as it can change without this
metatable being updated)
create separate schema for each user

Safely migrating tables and columns in mysql

We're looking to change the names of a large number of tables in our database. Is there a safe way to remain backwards compatible when we do this?
For example, if our code references table A, and we want to rename table A to table B, can we alias the table A commands so that they are sent to table B? That way we can migrate the database first, then we can migrate the application over time to point to the new table.
Sounds like it could be done with Views, for example after doing this:
CREATE VIEW A AS SELECT * FROM B;
anything querying A, would actually get the data from real table B.
However their behavior is not the same as tables, so it may not be suitable, first check:
https://dev.mysql.com/doc/refman/5.7/en/view-restrictions.html

How to synchronize view table to manual temporary table?

I have tables in database that consist of so many data records. I made view tables because I joined the tables. Then, when I tried to open the view tables, the time took so long because the tables had many data. So, I decided to make temporary table like this:
CREATE TABLE temp_ AS (SELECT * FROM view)
then, I want to synchronize the view and temporary table. As the example, when I tried to update the view table, then we're able to know that the temporary table has to change too because the temporary is synchronized with the view table. Maybe, it can be solved when the view's updated time > generated time than we have to update the table
I have table like this
I manually inserted the data records to both of that table. What may I do to synchronize them? Thanks in advance

Cant copy unique records from one database table to another?

Hi,
I am trying to copy unique records from a database table to another table of the same name but different database. The source database contains some records that are already present in the destination database, so those I dont need, only the other ones. Database destination is called "test" and the source database is "forums". The table name is store for both cases. I am using this query:
INSERT INTO test.store (cs_key, cs_value, cs_array, cs_updated,cs_rebuild)
SELECT DISTINCT cs_key, cs_value, cs_array, cs_updated,cs_rebuild
FROM forums.store
But I am getting many errors as I try to run this query. Why?
Thank you.