Select a non existing column in mysql
mysql
Solution
Yes sure, You can named column with `as` keyword. For example:
SELECT 1 as 'hello'
And You can simply add RowNumber column like below example:
SELECT t.*,
@rownum := @rownum + 1 as RowNumber
FROM your_table t,
(SELECT @rownum := 0) r
For start from `149`, You just need to replace `(SELECT @rownum := 0)` with `(SELECT @rownum := 149)`
For a dummy column with the certain type, Use `Cast` or `Convert` functions like this: `CAST(@rownum := @rownum + 1 AS CHAR) AS RowNumber`. You can find more about this here: http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html
More Examples related to the comments:
SELECT
COUNT(col1) AS col2
FROM your_table
GROUP BY col2
HAVING col2 = 2;
@nodsdorf example in the comments:
SELECT
(1+1) AS dummy,
other_column
FROM table
Problem
Is it possible say for example i want to select a column which does not exist in an mysql table, i just want this column to have incremental values starting from "somevalue (100 maybe)". I want something like this: ``` my dummy column | other existing columns | blah 100 101 102 ``` is this possible in mysql?