Reputation: 85
I want to export a tablet with a lot of columns (20+). I want to exclude the primary key, but don't want to write SELECT column2
,column3
and so on for all the rest columns. I want to export the data without primary key so when I import it, the primary key will be auto incremented. I am using MySql and PhpMyAdmin.
Upvotes: 1
Views: 3431
Reputation: 7722
See this answer found in select-all-columns-except-one-in-mysql:
SET @sql = CONCAT('SELECT ', (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), '<columns_to_omit>,', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '<table>' AND TABLE_SCHEMA = '<database>'), ' FROM <table>');
PREPARE stmt1 FROM @sql;
EXECUTE stmt1;
This helped me a lot on a simmilar problem.
Upvotes: 1