How to add not null constraint to existing column in MySQL

I have table name called “Person” with following column names P_Id(int), LastName(varchar), FirstName (varchar). I forgot to give NOT NULL Constraint to P_Id. Now I tried with following query to add NOT NULL Constraint to existing column called P_Id, 1. ALTER TABLE Person MODIFY (P_Id NOT NULL); 2. ALTER TABLE Person ADD CONSTRAINT NOT NULL … Read more

MySQL: Sort GROUP_CONCAT values

In short: Is there any way to sort the values in a GROUP_CONCAT statement? Query: GROUP_CONCAT((SELECT GROUP_CONCAT(parent.name SEPARATOR ” &raquo; “) FROM test_competence AS node, test_competence AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt AND node.id = l.competence AND parent.id != 1 ORDER BY parent.lft) SEPARATOR “<br />\n”) AS competences I get this row: Crafts … Read more

UPDATE multiple rows with different values in one query in MySQL

I am trying to understand how to UPDATE multiple rows with different values and I just don’t get it. The solution is everywhere but to me it looks difficult to understand. For instance, three updates into 1 query: UPDATE table_users SET cod_user=”622057″ , date=”12082014″ WHERE user_rol=”student” AND cod_office=”17389551″; UPDATE table_users SET cod_user=”2913659″ , date=”12082014″ WHERE … Read more

#1273 – Unknown collation: ‘utf8mb4_unicode_ci’ cPanel

I have a WordPress database on my local machine that I want to transfer to a hosted phpMyAdmin on cPanel. However, when I try to import the database into the environment, I keep getting this error: #1273 – Unknown collation: ‘utf8mb4_unicode_ci’ I have tried to Google around and the only solution I can find is … Read more