November 8th, 2012, 06:14 PM
Using a value from another table in a where clause...
This is the code I have now...
I want to add a date comparison to the where clause.
CREATE DEFINER=`lifeprojectrpg`@`localhost` PROCEDURE `BankingTableDump`(IN rowid INT(12))
SELECT playeruid, money
WHERE id = rowid;
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 .
November 9th, 2012, 07:38 AM
November 9th, 2012, 08:52 AM
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?'
November 9th, 2012, 10:16 AM
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 .