A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

New answers tagged

0

As per suggested by Mr. Barmar it was causing due to --skip-grant-tables in MySQL. To disable this option just run FLUSH PRIVILEGES; command in your MySQL CLI and this will solve the issue.


0

Use additional table for roles: CREATE TABLE ROLES (ID INT, NAME VARCHAR(30), PRIMARY KEY(ID)); INSERT INTO ROLES (ID, NAME) VALUES(1, 'Publisher'); INSERT INTO ROLES (ID, NAME) VALUES(2, 'Editor'); INSERT INTO ROLES (ID, NAME) VALUES(3, 'Viewer'); Then your PERMISSIONS table could look as follows: CREATE TABLE PERMISSIONS ( USER_ID INT NOT NULL, ...


0

Using the SQL will get you the invoice and json aggregated items in an array: SELECT invoice, JSON_ARRAYAGG(item) FROM tablename GROUP BY invoice


0

BEGIN; INSERT the row calculate the rank; put it into an app variable ROLLBACK; The ROLLBACK lets you undo the INSERT. But meanwhile, you have grabbed the rank.


-1

Where does the new data come from? Do you just manually type it? If the data is coming from an application, you may declare a variable with its ID then before insert it, you make a select query that will count the rank of the new data before it's added to the table. If you insert data one by one, then declaring variable is your best choice. You just need ...


Top 50 recent answers are included