djp1988 Posted March 26, 2009 Share Posted March 26, 2009 Hi all the following is taken from mysql.com CREATE PROCEDURE simpleproc (OUT param1 INT) BEGIN SELECT COUNT(*) INTO param1 FROM t; END; What i wanted to know is the syntax to select a database for this query, as the mysql error message for this is:===#1046 - No database selected === Link to comment Share on other sites More sharing options...
justsomeguy Posted March 26, 2009 Share Posted March 26, 2009 Check the documentation for MySQL. It's probably something like USE or DATABASE. Link to comment Share on other sites More sharing options...
djp1988 Posted March 28, 2009 Author Share Posted March 28, 2009 Hi, can't seem to get it working still... Link to comment Share on other sites More sharing options...
Synook Posted March 29, 2009 Share Posted March 29, 2009 What is your complete code? Link to comment Share on other sites More sharing options...
djp1988 Posted March 30, 2009 Author Share Posted March 30, 2009 I don't have one, I am just try to manually make a stored procedure, and I can't because i can't find out how to select a database to use in the sql Link to comment Share on other sites More sharing options...
Synook Posted March 31, 2009 Share Posted March 31, 2009 I mean what is the query you are trying to use at the moment to select the DB? It should be something like USE database Link to comment Share on other sites More sharing options...
djp1988 Posted March 31, 2009 Author Share Posted March 31, 2009 I'm not, I have this query: CREATE PROCEDURE simpleproc (OUT param1 INT) BEGIN SELECT COUNT(*) INTO param1 FROM t; END; And the mysql error says I need to add into the SQL the syntax to select a database to use, so i don't understand Link to comment Share on other sites More sharing options...
Synook Posted April 1, 2009 Share Posted April 1, 2009 Did you try USE? USE database;CREATE PROCEDURE simpleproc (OUT param1 INT) BEGIN SELECT COUNT(*) INTO param1 FROM t; END; Where database is your db name. Link to comment Share on other sites More sharing options...
shyam Posted July 13, 2009 Share Posted July 13, 2009 USE database;CREATE PROCEDURE simpleproc (OUT param1 INT) BEGIN SELECT COUNT(*) INTO param1 FROM t; END;if your table contain two field id and nameu should writeCREATE PROCEDURE simpleproc (OUT param1 INT) BEGIN SELECT COUNT(id) INTO param1 FROM t; END;you can write name instand of id; Link to comment Share on other sites More sharing options...
uwspstar Posted July 15, 2009 Share Posted July 15, 2009 Hi all the following is taken from mysql.comCREATE PROCEDURE simpleproc (OUT param1 INT) BEGIN SELECT COUNT(*) INTO param1 FROM t; END; What i wanted to know is the syntax to select a database for this query, as the mysql error message for this is:===#1046 - No database selected === try something like this SELECT COUNT(*) = @var FROM t@var should be your param1 Link to comment Share on other sites More sharing options...
skaterdav85 Posted December 19, 2009 Share Posted December 19, 2009 ive tried researching it but I get mixed responses. Can you create SP in phpmyadmin, or just through the command line? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.