MySQL Forums
Forum List  »  Newbie

Help writing a procedure
Posted by: Johann Wolf
Date: February 06, 2013 05:49PM

I would like some help in writing a procedure to generate a match between 2 users
I have a users table that holds ID and name. I have a match table that holds ID,date, tounament id as fk and 2 userids from 2 one to one relationships from user table. I have a tournament table which holds and id, date , name and enddate. the users table is connected to the tournament table via weak entity which holds both ids and both user and tournament are connected to the matches. what im trying to do is select ids from weak entity between user and tournament and based on that i will populate the matches as long as their is 2 payers in the same league. I can post my creates if this helps?
This is what i compiled but when i call it i get an error sql (1222) The used select statements have a different number of columns
DELIMITER //
CREATE PROCEDURE genMatches(IN tourid INT(11), IN userid INT(11), IN userid1 INT (11)))
BEGIN
DECLARE a INT;
select tb_tournament_TOURID , tb_users_UID
from tb_tournament_has_tb_users
where tb_tournament_TOURID = tourid AND tb_users_UID = userid AND tb_users_UID = userid1
INTO a;
IF (a > 0) THEN
INSERT INTO tb_matches (date,tb_tournament_TOURID,tb_users_UID,tb_users_UID1) values (sysdate,tourid,userid,userid1);
END IF;
END //

Sorry for the essay

Options: ReplyQuote


Subject
Written By
Posted
Help writing a procedure
February 06, 2013 05:49PM
February 06, 2013 06:09PM
February 06, 2013 06:20PM
February 06, 2013 06:22PM
February 10, 2013 10:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.