About 158,000 results
Open links in new tab
  1. Create a view with column row_num - MySQL - Stack Overflow

    Then create the view as following: CREATE OR REPLACE VIEW myview (place, name, hour, price, counter) AS SELECT place, name, hour, price, func_inc_var_session() FROM yourtable WHERE input_conditions_here; The trick here is that you may see NULL on the counter column.

  2. How do I get MySQL to use an INDEX for view query?

    Dec 19, 2012 · I've getting suggestions from people that using views in MySql is not a good idea. Because you can't create index for views in mysql like in oracle. But in some test that I took, indexes can be used in view select statement. Maybe I've created those views in a wrong way. I'll use a example to describe my problem.

  3. How to create a View with a With statement? - Stack Overflow

    Aug 6, 2014 · If your WITH is the first line of defining your view, the semicolon is trying to terminate the view definition. EDIT: Responding to comment This may take a couple of passes, but the next step is to clean up your ROW_NUMBER column. replace your rowno = row_number() OVER (Partition by parit order.by taarich) with

  4. mysql - SQL - Create view from multiple tables - Stack Overflow

    I am trying to create a view such as: V(country, year, pop, food, income) This is my code so far. I don't think its correct: CREATE VIEW V AS (SELECT * FROM POP UNION SELECT * FROM FOOD UNION SELECT * FROM INCOME); One issue is, a country that is present in POP may not be present in FOOD. Same goes for year.

  5. sql - Creating View from Another View - Stack Overflow

    Feb 12, 2013 · create or replace view my_view_2 as select mv1.id, mv1.name, mt.address from my_view_1 mv1 join my_table mt on mt.id = mv1.id; view MY_VIEW_2 created. But you can't reference anything in the underlying tables, including any fields that are not part of the view:

  6. Create MySQL view with variables - Stack Overflow

    May 4, 2018 · You are possibly looking for dynamic sql where you build code to be executed. For example given. drop table if exists op_id,operations_20180101 ,operations_20180102 ; create table op_id (op_id int); insert into op_id values (20180101), (20180102); create table operations_20180101(username varchar(3) ,data int); create table operations_20180102(username varchar(3) ,data int); insert into ...

  7. Can I create view with parameter in MySQL? - Stack Overflow

    CREATE VIEW MyView AS SELECT Column, Value FROM Table; SELECT Column FROM MyView WHERE Value = 1; Is the proper solution in MySQL, some other SQLs let you define Views more exactly. Note: Unless the View is very complicated, MySQL will optimize this just fine.

  8. sql - How do MySQL views work? - Stack Overflow

    May 20, 2010 · Because a view is a derived table, the performance of the view is only as good as the query it is built on. If that query sucks, the performance issue will just snowball... That said, when querying a view - if a view column reference in the WHERE clause is not wrapped in a function (IE: WHERE v.column LIKE ..., not WHERE LOWER(t.column) LIKE ...

  9. Create comments for views in mysql - Stack Overflow

    -- create a new table to contain the view-level comments CREATE TABLE IF NOT EXISTS `schema_view` ( `schema_view_id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'unique primary key. auto increment. ', `schema_view_name` VARCHAR(64) NOT NULL COMMENT 'view name matches information_schema.tables.table_name for VIEW', `schema_view_comment` VARCHAR ...

  10. Can I create a view on a temporary tables in MySQL?

    Dec 7, 2021 · mysql> create temporary table foo ( i int ); Query OK, 0 rows affected (0.00 sec) mysql> create view v as select * from foo; ERROR 1352 (HY000): View's SELECT refers to a temporary table 'foo' It makes sense if you think about it. A view should be usable by other sessions. But a temporary table is limited to the current session where it is created.

Refresh