I need to create a view that has a column named row_num where it will be inserted the row number, just like an auto increment in a normal table.
Let\'s say I\'ve thi
Or try this-> create a temporary table and insert your data into it like bellow
CREATE OR REPLACE TEMPORARY TABLE myview (
country VARCHAR(250),
name VARCHA(50),
price VARCHAR(50),
row_num int(11)
);
SET @row_num = 0;
INSERT INTO myview (country,name,price,row_num)
SELECT @row_num:=@row_num+1
as country,name,price,row_num
FROM testing;
SELECT * FROM myview;
+---------+------+------+-------+---------+
| country | name | age | price | row_num |
+---------+------+------+-------+---------+
| Sweden | Alex | 49 | 10 | 1 |
| France | Anne | 10 | 15 | 2 |
| France | Anne | 11 | 16 | 3 |
| US | john | 22 | 20 | 4 |
+---------+------+------+-------+---------+