Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sql Sytnax

Posted on 2008-10-15
1
Medium Priority
?
245 Views
Last Modified: 2012-05-05
Hello I need help with an update statment.
Table1: LinkID, Width, Height, UserID, Status
Table2: UserID, Credits

How can i do something like If Width * Height < Credits Then Set Status = 22.
I need to do this for each record in Table1 which is why Im having trouble writing it myself.

Thanks
0
Comment
Question by:grogo21
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 60

Accepted Solution

by:
chapmandew earned 2000 total points
ID: 22727224
update t1
set status = case when (width * height) < credits then 22 else t1.status end
from table1 t1
join table2 t2 on t1.userid = t2.userid

or, you can do it this way (probably the better approach, as only the records that meet your criteria are updated.)

update t1
set status = 22
from table1 t1
join table2 t2 on t1.userid = t2.userid
where  (width * height) < credits
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question