Mastering MySQL 4 [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Mastering MySQL 4 [Electronic resources] - نسخه متنی

Ian Gilfillan

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







More about Adding Records

INSERT also allows a syntax similar to the one used by an UPDATE statement. Instead of saying the following:

mysql> INSERT INTO customer_sales_values(first_name, surname, value)
VALUES('Charles', 'Dube', 0);

you could say this:

mysql> INSERT INTO customer_sales_values SET first_name =
'Charles', surname='Dube', value=0;

You can also do a limited form of calculation when you add records. To demonstrate, add another field onto the customer_sales_value table:

mysql> ALTER TABLE customer_sales_values ADD value2 INT;

Now, you can insert into this table and populate value2 with twice the value:

mysql> INSERT INTO customer_sales_values(first_name, surname, value,
value2) VALUES('Gladys', 'Malherbe', 5, value*2);

This record now contains the following:

mysql> SELECT * FROM customer_sales_values WHERE first_name='Gladys';
+------------+----------+-------+--------+
| first_name | surname | value | value2 |
+------------+----------+-------+--------+
| Gladys | Malherbe | 5 | 10 |
+------------+----------+-------+--------+


/ 229