Solved

Sql Sytnax

Posted on 2008-10-15
1
209 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
1 Comment
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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. …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now