MySQL Forums
Forum List  »  Stored Procedures

how can i do this procedure
Posted by: fmb fmb
Date: December 02, 2008 02:51AM

hi all,
i have 2 tables:
CREATE TABLE IF NOT EXISTS `languages` (
`language_id` int(11) NOT NULL auto_increment,
`ISO639-1Code` char(2) collate utf8_unicode_ci default NULL,
`status` smallint(2) NOT NULL,
PRIMARY KEY (`language_id`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `languages_names` (
`language_id` int(11) NOT NULL,
`name_in` int(11) NOT NULL,
`name` varchar(150) collate utf8_unicode_ci default NULL,
PRIMARY KEY (`language_id`,`name_in`)
) ENGINE=MyISAM;

i need to modify this procedure:

DROP PROCEDURE `langs`//
CREATE DEFINER=`root`@`localhost` PROCEDURE `langs`(IN inLanguageId INT)
BEGIN
SELECT language_id, name
FROM languages_names
WHERE name_in = inLanguageId
ORDER BY language_id;
END

i select to return all language_id and name from languages_names table that have name_in = inLanguageId(value i pass to the procedure), but what i need to add another condition i have:
WHERE name_in = inLanguageId
add something like this
WHERE name_in = inLanguageId AND language_id from table languages(the other table) field 'status' = 1,
in both tables language_id are the same in table languages_names i select language_id from table languages, i try to select all language_id and name from table languages_names that have name_in field of this table = value i pass to the procedure and the status of language_id at table languages is set to 1,
thanks a lot

Options: ReplyQuote


Subject
Views
Written By
Posted
how can i do this procedure
2568
December 02, 2008 02:51AM


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.