mysql ÀÛ¼ÓÔËËã - ÆäËûÊý¾Ý¿â¿ª·¢ / MySQL/Postgresql
sp ³ÌÐò
delimiter //
create procedure ma()
begin
declare i int default 0;
while i<11 do
set i=i+1;
select i;
end while;
end //
delimiter ;
1+2+...+9+10
ΪʲôÕâ¸ö³ÌÐòÎÞ·¨ÊµÏÖÀÛ¼ÓЧ¹û
//Çë˵Ã÷Õâ¸ö³ÌÐòµÄȱÏݺ͸Ľø·½·¨¡£¡£Ð»Ð»¸÷λ´ó¸ç
SQL code:
mysql> call ma();
+------+
| j |
+------+
| 55 |
+------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
˳±ãÎÊÒ»ÏÂ
SQL code:
delimiter //
create procedure test07()
begin
declare i int ;
set i=1; --Õâ¸öµØ·½ÉèÖóÉi=1 ¿ÉÒÔÊäÈëµã¶«Î÷¡£¡£µ«ÊÇi=0ΪʲôÊÇÎÞÏÞÑ»·£¿
while i<10 do
set i=i+1;
select i;
end while;
end //
delimiter ;
º¹£¬Äã±¾ÉíµÄ³ÌÐòÊÇÍù±äÁ¿IÒ»Ö±ÀÛ¼Ó1¡£ ×Ðϸ¿´Ï¾ÍÃ÷°×ÁË¡£
Ïà¹ØÎÊ´ð£º
String sqlCount="select count(*) from usertable where username='"+
userName+"'";Õâ¾ä»° ʲôÒâ˼°¡£¡
Õâ¾ä»°Êä³ö³öÀ´¾ÍÊÇ
select count(*) from usertable where username='ÄãµÄ±äÁ¿ ......
1¡¢ÊDz»ÊÇPHPÖÐÖ»ÄÜʹÓÃmysql_query("update user_aa set money=money2-".$bpanmm." where uid=".$userppp);¸üÐÂÊý¾Ý£¿£¿£¿
2¡¢PHP¸üÐÂmysql_fetch_row($res)Óëmysql_fetch_array($res)ÖеÄÊý¾ ......
ÎÒÓõÄÊÇmysql6.0Ϊʲôһ´´½¨Á½¸ö±íÕâ¼äÓÃÍâ¼üÀ´Á¬½Óʱ¾Í˵´´½¨²»ÁË£ºcan"nt create table ...
ÄãµÄÓï¾äÊÇʲô£¿ÄãµÄ±íÊÇʲô´æ´¢ÒýÇæ£¿ Èç¹ûÊÇmyisam Ôò²»Ö§³ÖÍâ¼ü£¬ÄãÐèÒª°Ñ±í¸ÄΪinndb
貼³öSQL ......
ÓÃmysql½¨±íʱ³öÏÖ´íÎó1067 £ºinvalid default value for 'id'
idÊÇintÐ͵ģ¬ÎªÊ²Ã´²»ÄÜÉèÖÃĬÈÏÖµ¡£Óï¾äΪid int£¨4£©default '-1' null;³öÏÖ´íÎó¡£
Ìù³öÄãµÄ create table Óï¾ä£¬¼°ÄãµÄmysql °æ±¾¡£
µ±ÄúµÄÎÊ ......
SELECT * from alarms where id in (select resource_id from res_products where product=22)
Õâ¸öÓï¾äÔÚmysqlÖÐΪʲô²»ÄÜÖ´ÐУ¿ÎÒµÄmysqlÊý¾Ý¿âÊÇ5.0.27°æ±¾µÄ£¡
Èç¹ûʵÔÚ²»ÐÐÄÇô¸ÃÓøöʲôÓï¾ä´úÌæÐ§Âʸü¸ßÄØ ......