SQL Question Emergency
I have a quick question about T-SQL syntax - anyone got a minute?
I need to do an update query - such as the one below (example from http://doc.ddart.net/mssql/sql70/ua-uz_3.htm)
SET ytd_sales = t.ytd_sales + s.qty
FROM titles t, sales s
WHERE t.title_id = s.title_id
AND s.ord_date = (SELECT MAX(sales.ord_date) FROM sales)
This one says to update the value in the Titles table based on a value in the Sales table, and I'm clear on this part.
My question is, can I use that FROM clause if I'm not pulling the value from another table. More specifically, can I do:
SET ytd_sales = "Not Availbable"
FROM titles t, sales s
WHERE t.title_id = s.title_id
AND s.ord_date = Getdate()-1
Basically, I want to use that FROM in order to limit which values get updatebased on thier related values in another table. However, I'm not setting hte field equal to a value in that table.....
I know this might not sound urgent, but it really is.
X-Posted everywhere i coudl think of. Sorry!
I need to do an update query - such as the one below (example from http://doc.ddart.net/mssql/sql70/ua-uz_3.htm)
SET ytd_sales = t.ytd_sales + s.qty
FROM titles t, sales s
WHERE t.title_id = s.title_id
AND s.ord_date = (SELECT MAX(sales.ord_date) FROM sales)
This one says to update the value in the Titles table based on a value in the Sales table, and I'm clear on this part.
My question is, can I use that FROM clause if I'm not pulling the value from another table. More specifically, can I do:
SET ytd_sales = "Not Availbable"
FROM titles t, sales s
WHERE t.title_id = s.title_id
AND s.ord_date = Getdate()-1
Basically, I want to use that FROM in order to limit which values get updatebased on thier related values in another table. However, I'm not setting hte field equal to a value in that table.....
I know this might not sound urgent, but it really is.
X-Posted everywhere i coudl think of. Sorry!
