GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Friday, March 18, 2011

MySQL - View

If you have a base table like this one:
Table car:
   id INT NOT NULL AUTO_INCREMENT KEY,
   brand CHAR(50) NOT NULL UNIQUE
   owner CHAR(50) NOT NULL DEFAULT ''

Then you can have the view like this one:
mysql> CREATE VIEW v_car
       AS SELECT * FROM car
mysql> CREATE VIEW v_car
                 AS SELECT DISTINCT(owner) FROM car
mysql> CREATE VIEW v_car (nama, pemilik)
       AS SELECT brand, owner FROM car
Share/Bookmark

No comments:

Post a Comment