37

How do I create a view in MySQL?

Ricardo Altamirano
  • 14,650
  • 21
  • 72
  • 105
Fero
  • 12,969
  • 46
  • 116
  • 157
  • 11
    Do you have any problem with the manual? http://dev.mysql.com/doc/refman/5.0/en/create-view.html – Nicola Cossu Mar 03 '11 at 20:08
  • 2
    @@nick rulez: I always trust stackoverflow for different types of suggestions and answers. that's y i posted here. – Fero Mar 05 '11 at 06:48
  • 2
    Thanks for the compliment. However, we'd rather you try to figure it out first. – mellamokb Mar 05 '11 at 13:01
  • @@mella: Thanks for your advice mella. Hereafter i will do the same and if i didn't get my exact answer i will come here... :-) – Fero Mar 07 '11 at 04:40
  • http://bindasmonkeys.com/views-mysql-create/ –  Mar 18 '16 at 07:15
  • mellamokb its better to just get simple answers from all these stack overflow experts than hunt for answers from all over the web. – webs Jan 03 '18 at 16:18

2 Answers2

56

http://dev.mysql.com/doc/refman/5.5/en/create-view.html

Example:

Create View `MyViewName` as 
    Select
        col1, col2, col3
    From
        myTable T
mellamokb
  • 56,094
  • 12
  • 110
  • 136
8
CREATE VIEW v AS SELECT * FROM t;
John K.
  • 5,426
  • 1
  • 21
  • 20