MySQL Help
 
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 ForumsDatabasesMySQL Help

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 November 8th, 2012, 05:14 PM
Brute Brute is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 10 Brute User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 23 m 2 sec
Reputation Power: 0
Using a value from another table in a where clause...

This is the code I have now...

Code:
DELIMITER $$

CREATE DEFINER=`lifeprojectrpg`@`localhost` PROCEDURE `BankingTableDump`(IN rowid INT(12))
BEGIN
		SELECT playeruid, money 
		FROM banking
		WHERE id = rowid;
    END


I want to add a date comparison to the where clause.

So basically the column is in the "information" table and it's called "lastlogin", it's in the format yyyymmdd (20121108). I want to subtract that from the current date and then if that equals greater than 15 or whatever integer then I want the whole query to return -1 and that's all, nothing else, but if it doesn't, if it equals less then run the above code normally and return the playeruid and the money. The lastlogin should be selected using the playerid which is selected from the "banking" table.

I've been trying to work this out for a couple of hours now and it's just beyond me so I would appreciate any help .

Reply With Quote
  #2  
Old November 9th, 2012, 06:38 AM
Brute Brute is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 10 Brute User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 23 m 2 sec
Reputation Power: 0
Anyone? .

Reply With Quote
  #3  
Old November 9th, 2012, 07:52 AM
cafelatte cafelatte is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Mar 2008
Posts: 1,923 cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 16 h 21 m 8 sec
Reputation Power: 377
Perhaps you're trying to solve too many problems at once:
- how to write a procedure
- how to write a query
- how to return two different kinds of thing (-1 vs result set)

If it was me, I'd try breaking it down into smaller steps starting with 'I have a table like this... CREATE etc... with data like this... INSERT etc... and another table like this...CREATE etc ... with data like this... How do I get a result like this?'

Reply With Quote
  #4  
Old November 9th, 2012, 09:16 AM
Brute Brute is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 10 Brute User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 23 m 2 sec
Reputation Power: 0
I know how to do it in two different querys but I want to condense it into one and I can't figure out how to, which is why I'm asking for help .

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Using a value from another table in a where clause...

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