HTML5¼¼Êõ

Ò»¸öСʱѧ»áMySQLÊý¾Ý¿â - ÕŹû(5)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-03-09 17:01 ÎÒÒªÆÀÂÛ( )

where ×Ӿ䲻½ö½öÖ§³Ö "where ÁÐÃû = Öµ" ÕâÖÖÃûµÈÓÚÖµµÄ²éѯÐÎʽ, ¶ÔÒ»°ãµÄ±È½ÏÔËËãµÄÔËËã·û¶¼ÊÇÖ§³ÖµÄ, ÀýÈç =¡¢¡¢¡¢=¡¢¡¢!= ÒÔ¼°Ò»Ð©À©Õ¹ÔËËã·û is [not] null¡¢in¡¢like µÈµÈ¡£ »¹¿ÉÒÔ¶Ô²éѯÌõ¼þʹÓà or ºÍ and

where ×Ӿ䲻½ö½öÖ§³Ö "where ÁÐÃû = Öµ" ÕâÖÖÃûµÈÓÚÖµµÄ²éѯÐÎʽ, ¶ÔÒ»°ãµÄ±È½ÏÔËËãµÄÔËËã·û¶¼ÊÇÖ§³ÖµÄ, ÀýÈç =¡¢>¡¢<¡¢>=¡¢<¡¢!= ÒÔ¼°Ò»Ð©À©Õ¹ÔËËã·û is [not] null¡¢in¡¢like µÈµÈ¡£ »¹¿ÉÒÔ¶Ô²éѯÌõ¼þʹÓà or ºÍ and ½øÐÐ×éºÏ²éѯ, ÒÔºó»¹»áѧµ½¸ü¼Ó¸ß¼¶µÄÌõ¼þ²éѯ·½Ê½, ÕâÀï²»ÔÙ¶à×ö½éÉÜ¡£

ʾÀý:

²éѯÄêÁäÔÚ21ËêÒÔÉϵÄËùÓÐÈËÐÅÏ¢: select * from students where age > 21;

²éѯÃû×ÖÖдøÓÐ "Íõ" ×ÖµÄËùÓÐÈËÐÅÏ¢: select * from students where name like "%Íõ%";

²éѯidСÓÚ5ÇÒÄêÁä´óÓÚ20µÄËùÓÐÈËÐÅÏ¢: select * from students where id<5 and age>20;

5.2.2¡¢¾ÛºÏº¯Êý

 

5.3¡¢É¾³ýÊý¾Ý

delete from ±íÃû [ɾ³ýÌõ¼þ];

ɾ³ý±íÖÐËùÓÐÊý¾Ý£ºdelete from students;

ɾ³ýidΪ10µÄÐÐ: delete from students where id=10;

ɾ³ýËùÓÐÄêÁäСÓÚ88ËêµÄÊý¾Ý: delete from students where age<88;

5.4¡¢¸üÐÂÊý¾Ý

update Óï¾ä¿ÉÓÃÀ´Ð޸ıíÖеÄÊý¾Ý, »ù±¾µÄʹÓÃÐÎʽΪ:

update ±íÃû³Æ set ÁÐÃû³Æ=ÐÂÖµ where ¸üÐÂÌõ¼þ;

Update ±íÃû set ×Ö¶Î=Öµ ÁÐ±í ¸üÐÂÌõ¼þ

ʹÓÃʾÀý:

½«idΪ5µÄÊÖ»úºÅ¸ÄΪĬÈϵÄ"-": update students set tel=default where id=5;

½«ËùÓÐÈ˵ÄÄêÁäÔö¼Ó1: update students set age=age+1;

½«ÊÖ»úºÅΪ 13723887766 µÄÐÕÃû¸ÄΪ "ÕŹû", ÄêÁä¸ÄΪ 19: update students set, age=19 where tel="13723887766";

5.5¡¢Ð޸ıí

alter table Óï¾äÓÃÓÚ´´½¨ºó¶Ô±íµÄÐÞ¸Ä, »ù´¡Ó÷¨ÈçÏÂ:

5.5.1¡¢Ìí¼ÓÁÐ

»ù±¾ÐÎʽ: alter table ±íÃû add ÁÐÃû ÁÐÊý¾ÝÀàÐÍ [after ²åÈëλÖÃ];

ʾÀý:

ÔÚ±íµÄ×îºó×·¼ÓÁÐ address: alter table students add address char(60);

ÔÚÃûΪ age µÄÁкó²åÈëÁÐ birthday: alter table students add birthday date after age;

5.5.2¡¢ÐÞ¸ÄÁÐ

»ù±¾ÐÎʽ: alter table ±íÃû change ÁÐÃû³Æ ÁÐÐÂÃû³Æ ÐÂÊý¾ÝÀàÐÍ;

ʾÀý:

½«±í tel ÁиÄÃûΪ phone: alter table students change tel phone char(12) default "-";

½« name ÁеÄÊý¾ÝÀàÐ͸ÄΪ char(9): alter table students change name name char(9) not null;

5.5.3¡¢É¾³ýÁÐ

»ù±¾ÐÎʽ: alter table ±íÃû drop ÁÐÃû³Æ;

ʾÀý:

ɾ³ý age ÁÐ: alter table students drop age;

5.5.4¡¢ÖØÃüÃû±í

»ù±¾ÐÎʽ: alter table ±íÃû rename бíÃû;

ʾÀý:

ÖØÃüÃû students ±íΪtemp: alter table students rename temp;

5.5.5¡¢É¾³ý±í

»ù±¾ÐÎʽ: drop table ±íÃû;

ʾÀý: ɾ³ýstudents±í: drop table students;

5.5.6¡¢É¾³ýÊý¾Ý¿â

»ù±¾ÐÎʽ: drop database Êý¾Ý¿âÃû;

ʾÀý: ɾ³ýlcoaÊý¾Ý¿â: drop database lcoa;

5.5.7¡¢Ò»Ç§ÐÐMySQL±Ê¼Ç

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • ÓÃDapperExtensionsºÍ·´ÉäÀ´ÊµÏÖÒ»¸öͨÓÃËÑË÷ - yt1983

    ÓÃDapperExtensionsºÍ·´ÉäÀ´ÊµÏÖÒ»¸öͨÓÃËÑË÷ - yt1983

    2017-03-09 08:00

  • [Ç°ÑÔ] ʵÏÖÒ»¸öAndroidµç×ÓÊéÔĶÁAPP - xfangs

    [Ç°ÑÔ] ʵÏÖÒ»¸öAndroidµç×ÓÊéÔĶÁAPP - xfangs

    2017-03-04 09:03

  • ÎÒÎÊÎÒ×Ô¼º£¬Ä㾿¾¹Ïë³ÉΪһ¸öʲôÑùµÄÈË£¿ - Felix_ICanFixIt

    ÎÒÎÊÎÒ×Ô¼º£¬Ä㾿¾¹Ïë³ÉΪһ¸öʲôÑùµÄÈË£¿ - Felix_ICanFixIt

    2017-03-01 08:00

  • SuperWebClient -Ò»¸ö»ùÓÚCURLµÄ.NET HTTP/HTTPSÄ£ÄâÉñ×é¼þ£¨1£© - ByteWorke

    SuperWebClient -Ò»¸ö»ùÓÚCURLµÄ.NET HTTP/HTTPSÄ£ÄâÉñ×é¼þ£¨1£© - B

    2017-02-28 12:01

ÍøÓѵãÆÀ
Ë