All user applications request data from the SQL databases by sending Transact-SQL (T-SQL) statements to the SQL server, including SELECT and UPDATE T-SQL statements. The UPDATE statement changes the existing SQL Server data in one or more columns of a database table or a database view. The SELECT statement gives users the ability to limit a set of records used in database operations. By using the T-SQL SELECT statement inside of an UPDATE statement you can fulfil a conditional user query on a SQL database.
- Skill level:
Other People Are Reading
Click "Start" in Windows and then click "Microsoft SQL Management Console."
Enter the following T-SQL code in the open window:
SET ytd_sales =
(SELECT SUM(qty) FROM sales WHERE sales.title_id = titles.title_id AND sales.ord_date IN (SELECT MAX(ord_date) FROM sales))
FROM titles, sales
Click "File' and then click "Save" to update sales data within the selected date range.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for