Migrate K2 items to Joomla! articles in two easy steps using phpMyAdmin

K2 is great but if you are in the mission of removing a dependency on any third-party extensions and migrate K2 items to Joomla articles then this article will help you.

1. Migrate K2 categories to Joomla

  • Access phpMyAdmin and go to SQL Query box of respective database
  • Enter following queries in query box and click on Go

phpmyadmin-querybox

insert into geek_categories (title, alias, parent_id, published, access, extension) select name, alias, parent, published, access, ‘com_content’, from geek_k2_categories 

Note: you got to change from geek to your database tables prefix. You can find tables prefix name from Server tab under Joomla Administrator>>System>>Global Configuration

2. Migrate K2 items to Joomla

  • Enter below queries into query box and click on Go
INSERT INTO `database_geek`.`geek_content` (`id`, `title`, `alias`, `catid`, `introtext`, `fulltext`, `created`, `created_by`, `publish_up`, `publish_down`, `access`) SELECT `id`, `title`, `alias`, `catid`, `introtext`, `fulltext`, `created`, `created_by`, `publish_up`, `publish_down`, `access` FROM `database_geek`.`geek_k2_items`

Note: you got to change two things here.

database_geek – change with your database name

geek – change the table prefix as you found in step number 1

Now, you should have K2 items into Joomla! content. This has helped me when I migrated K2 to Joomla and hope it will you too.

Reader Interactions

Comments

  1. i get this error:
    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘from xxxxx_k2_categories’ at line 1

  2. i have same error
    mysql 5.5.35 php 5.3 phpmyadmin 4.4.6

    query:

    insert into zap0v_categories (title, alias, parent_id, published, access, extension) select name, alias, parent, published, access, ‘com_content’, from zap0v_k2_categories

    error: near ‘from zap0v_k2_categories’ at line 1

  3. I get this error
    #1054 – Unknown column ‘‘com_content’’ in ‘field list’

  4. Hi, Thans for the codes.

    For the first one I had to change the (‘) signs.

    For the second one I am getting this code.
    What should I do?

    #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’

    Thanks!!!

  5. I get this error
    #1054 – Unknown column ‘‘com_content’’ in ‘field list’

    Can anyone help me please?

  6. I cant make tis to work, I have this message:
    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘from prefix_k2_categories’ at line 1

    I tried the xtra comma, etc

  7. Hi Graham, the same issue like others.
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘from hrk32qe_k2_categories’ at line 1

    Please, update this post and help us!
    Thanks!

  8. insert into mainj_categories (title, alias, parent_id, published, access, extension) select name, alias, parent, published, access, mainj_content, From mainj_k2_categories

    MySQL said: Documentation
    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘From mainj_k2_categories’ at line 1

  9. If you have this error in MariaDB : #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘from xxxxx_k2_categories’ at line 1

    You need to do something like that :

    INSERT INTO dzzz_categories (title,alias,parent_id,published,access,extension) SELECT name,alias,parent,published,access,’com_content’ FROM dzzz_k2_categories

  10. So…the summary
    For the first code – remove the comma before ‘from’
    For the second code – just insert IGNORE after INSERT, as wph4 already told here above.

    Good luck to everyone!

  11. Everything worked with no SQL errors, but when I go to my categories I get the following warning:
    Warning: str_repeat(): Second argument has to be greater than or equal to 0 in \administrator\components\com_categories\views\categories\tmpl\default.php on line 193

    • Had the same problem but figured it out. It is because the parent level is messed up. The copied categories are having a level of ‘0’. You will have to change them to 1 or more

  12. HELP ME PLEASE

    I got the error #1054 – Unknown column ‘‘com_content’’ in ‘field list’
    i tried with INSERT IGNORE but keeps going on!
    Any Idea?

    INSERT IGNORE into xxxx_categories (title, alias, parent_id, published, access, extension) select name, alias, parent, published, access, ‘com_content’ from xxxx_k2_categories;

    • for:
      I got the error #1054 – Unknown column ‘‘com_content’’ in ‘field list’
      i tried with INSERT IGNORE but keeps going on!

      copy + paste the following and change to ur db prefixes … then change the quotation marks from ‘ to ‘

      so instead of ‘com_content’ it will be ‘com_content’
      ——————
      insert into geek_categories (title, alias, parent_id, published, access, extension) select name, alias, parent, published, access, ‘com_content’ from geek_k2_categories

      • this website changes them back to the wierd quotation marks…just delete the single quotation mark around com_content and write them back again…should work

  13. So, would you be so kind to tell us how to catch up K2 featured images (first header image) of articles too? It works but only with article content, excluding extrafields.

    Any ideas? Tnx

Comments

Your email address will not be published. Required fields are marked *