TAILIEUCHUNG - Beginning C# 2005 Databases PHẦN 2

Tuyên bố này bản sao tất cả các sản phẩm từ bảng sản phẩm có ProductName cột giá trị bắt đầu bằng chữ w vào một bảng được gọi là ProductW - trong đó có chính xác các đặc điểm kỹ thuật cùng một cột như sản phẩm. Các truy vấn được sử dụng để có được dữ liệu để chèn nhiều hàng không cần phải được đơn giản này. Các dữ liệu có thể đến từ nhiều bảng, và | Database Fundamentals The INSERT keyword can also be used to insert multiple columns into a table at the same time. However this cannot be achieved by specifying all of the column values as part of the statement. Instead you must specify column values indirectly by using a SQL statement that returns a set of data for example a select query. In insert statements of this form you must omit the VALUES keyword. The following is an example of a multirow insert query INSERT INTO ProductW ProductId ProductName Productcost ProductCategoryld SELECT ProductId ProductName ProductCost ProductCategoryId FROM Product WHERE ProductName LIKE w This statement copies all the products from the Product table whose ProductName column value starts with the letter w into a table called ProductW which has exactly the same column specification as Product. The query used to obtain data for inserting multiple rows needn t be this simple. The data could come from multiple tables and the source columns needn t have the same names as the destination columns as long as their types match. As with select statements there is a lot more that you can do with insert statements but these are the basics that you need to add data to database tables using SQL. Deleting Data You can delete data from databases using the DELETE keyword. But first a word of warning the delete statement makes it easy to accidentally delete the entire contents of a database table. The syntax for a delete statement is as follows DELETE FROM Table WHERE Filter Here Table is the table from which to delete data and Filter is a filter used to identify the data to delete. Delete statements operate on whole rows of data it is not possible to delete individual columns from rows. The FROM keyword is optional like the INTO keyword in insert statements it can be more readable to leave it in and the where clause is also optional. If the where clause is omitted all the rows in the table will be deleted. If you want this to happen fine. If .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.