MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 29th, 2012, 09:51 AM
fred2028 fred2028 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 142 fred2028 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 32 m 7 sec
Reputation Power: 7
Column logic

Hi, is there a way to make simple logic for columns in a table? For example, if a value in 2 columns are equal, then set a third column to TRUE.

Thanks
__________________
Cheers,
Fred Liu

Reply With Quote
  #2  
Old May 29th, 2012, 10:00 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,371 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 6 h 29 m 6 sec
Reputation Power: 4140
yes, but you would want to do this only in a SELECT query, not in the table itself as an actual column
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
  #3  
Old May 29th, 2012, 12:46 PM
fred2028 fred2028 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 142 fred2028 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 32 m 7 sec
Reputation Power: 7
Quote:
Originally Posted by r937
yes, but you would want to do this only in a SELECT query, not in the table itself as an actual column
Why is it not a good idea for the actual table to automatically change the 3rd column once the previous 2 columns are equal? I don't want to have to run a SELECT statement each time the table is updated.

Reply With Quote
  #4  
Old May 29th, 2012, 02:35 PM
Vomster's Avatar
Vomster Vomster is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 724 Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 2 h 26 m 31 sec
Reputation Power: 290
Seems like it would be another field to keep track of. Just worry about it at "run time".

That is the point r937 is trying to get across.

Reply With Quote
  #5  
Old May 29th, 2012, 08:31 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,371 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 6 h 29 m 6 sec
Reputation Power: 4140
Quote:
Originally Posted by fred2028
I don't want to have to run a SELECT statement each time the table is updated.
i agree completely, and you're in luck, you don't have to

just do your updates as normal, and of course don't update this mythical third column because it won't even be there

when you want to see the data, that's the only time you do the SELECT, and that includes the calculation



Last edited by r937 : May 29th, 2012 at 08:37 PM.

Reply With Quote
  #6  
Old May 30th, 2012, 09:58 AM
fred2028 fred2028 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 142 fred2028 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 32 m 7 sec
Reputation Power: 7
Quote:
Originally Posted by r937
i agree completely, and you're in luck, you don't have to

just do your updates as normal, and of course don't update this mythical third column because it won't even be there

when you want to see the data, that's the only time you do the SELECT, and that includes the calculation


OK thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Column logic

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap