I want to add it to another website which you can see here https://abwddemo.com/services. You can see that the space is there for the QUICKTOOLS menu but I cannot import the data into the database.
I was not able to import the sql file into the table so I just imported the table into the database and tried to copy all of the rows from the imported table to the menu table, but I get the error Duplicate entry ‘xxxx’ for key ‘PRIMARY’
After reading what I can find, and comprehend, I am no further ahead.
I start in the DB I want to take the rows from with the following statement
SELECT * FROM abcde_menu WHERE menutype=“quicktools”
From there I just import it into my Database: abwddemo_data, so I end up with a table that is foreign to the database.
I then try to copy the rows with this statement
INSERT INTO jlbkx_menu SELECT * FROM abcde_menu, and that is where I get the error.
I was successful once a year ago but there were changes made to the source database so I have to move it all again. Problem is, I cannot figure out what I did right the last time.
I’ve not tried this kind of data transfer, but looking at your query, the first idea that springs to mind is:-
Instead of SELECT *, you could select all columns except the ID.
The AI should give new IDs to the copied rows, and you won’t duplicate existing ones.
Is there a command that selects all columns except the ID? If I have to identify all columns, it will be a very long statement and prone to errors no doubt.
Look at the table definition for jlbkx_menu. The Primary Key for this table has been set, and at least 2 records in abcde_menu contain the same value in that field.
I dropped the id column in abcde_menu which was the Primary column, then tried to copy the remaining rows into jlbkx_menu but got another error #1136 - Column count doesn’t match value count at row 1
which I suspect means that the column count doesn’t match
If I am successful at this, there are 70 other websites where this menu needs to be imported into. Hence I need to find a way to do this easily vs. building the menu in each website
You should be listing out the columns in both the INSERT and the SELECT part of the query, so that if the structure of either table gets changed, the query will still work.
Export a .sql dump of each table. The INSERT … query within the .sql file lists all the columns. You can just copy/paste this into your code and remove the column(s) you don’t want.