Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

mysql sql °ÙÍò¼¶Êý¾Ý¿âÓÅ»¯·½°¸

1.¶Ô²éѯ½øÐÐÓÅ»¯£¬Ó¦¾¡Á¿±ÜÃâÈ«±íɨÃ裬Ê×ÏÈÓ¦¿¼ÂÇÔÚ where ¼° order by Éæ¼°µÄÁÐÉϽ¨Á¢Ë÷Òý¡£
2.Ó¦¾¡Á¿±ÜÃâÔÚ where ×Ó¾äÖжÔ×ֶνøÐÐ null ÖµÅжϣ¬·ñÔò½«µ¼ÖÂÒýÇæ
·ÅÆúʹÓÃË÷Òý¶ø½øÐÐÈ«±íɨÃ裬È磺
select id from t where num is null
¿ÉÒÔÔÚnumÉÏÉèÖÃ
ĬÈÏÖµ0£¬È·±£±íÖÐnumÁÐûÓÐnullÖµ£¬È»ºóÕâ
Ñù²éѯ£º
select id from t where num=0
3.Ó¦¾¡Á¿±ÜÃâÔÚ where ×Ó¾äÖÐʹÓÃ!=»ò<>²Ù×÷·û£¬·ñÔò½«ÒýÇæ·ÅÆúʹÓÃË÷Òý¶ø½øÐÐÈ«±íɨÃè¡£
4.Ó¦¾¡Á¿±ÜÃâÔÚ where ×Ó¾äÖÐʹÓà or À´Á¬½ÓÌõ¼þ£¬·ñÔò½«µ¼ÖÂÒýÇæ·ÅÆúʹÓÃË÷Òý¶ø½øÐÐÈ«±íɨÃ裬È磺
select id from t where num=10 or num=20
¿ÉÒÔÕâÑù²éѯ£º
select id from t where num=10
union all
select id from t where num=20
5.in ºÍ not in Ò²ÒªÉ÷Ó㬷ñÔò»áµ¼ÖÂÈ«±íɨÃ裬È磺
select id from t where num in(1,2,3)
¶ÔÓÚÁ¬ÐøµÄÊýÖµ£¬ÄÜÓà between ¾Í²»ÒªÓà in ÁË£º
select id from t where num between 1 and 3
6.ÏÂÃæµÄ²éѯҲ½«µ¼ÖÂÈ«±íɨÃ裺
select id from t where name like ‘%abc%’
ÈôÒªÌá¸ßЧÂÊ£¬¿ÉÒÔ¿¼ÂÇÈ«ÎļìË÷¡£
7.Èç¹ûÔÚ where ×Ó¾äÖÐʹÓòÎÊý£¬Ò²»áµ¼ÖÂÈ«±íɨÃè¡£ÒòΪSQL
Ö»ÓÐÔÚÔËÐÐʱ²Å»á½âÎö
¾Ö²¿±äÁ¿£¬µ«ÓÅ»¯³ÌÐò
²»Äܽ«·ÃÎÊ
¼Æ»®µÄÑ¡ÔñÍƳٵ½ÔËÐÐʱ£»Ëü±ØÐëÔÚ±àÒë
ʱ½øÐÐÑ¡Ôñ¡£È»
¶ø£¬Èç¹ûÔÚ±àÒëʱ½¨Á¢·ÃÎʼƻ®£¬±äÁ¿µÄÖµ»¹ÊÇδ֪µÄ£¬Òò¶øÎÞ·¨×÷ΪË÷ÒýÑ¡ÔñµÄÊäÈëÏî¡£ÈçÏÂÃæÓï¾ä½«½øÐÐÈ«±íɨÃ裺
select id from t where [email=num=@num]num=@num[/email]
<[email=num=@num]mailto:num=@num[/email]>
¿ÉÒÔ¸ÄΪǿÖƲéѯʹÓÃË÷Òý£º
select id from t with(index(Ë÷ÒýÃû)) where [email=num=@num]num=@num[/email]
<[email=num=@num]mailto:num=@num[/email]>
8.Ó¦¾¡Á¿±ÜÃâÔÚ where ×Ó¾äÖжÔ×ֶνøÐбí´ïʽ²Ù×÷£¬Õ⽫µ¼ÖÂÒýÇæ·ÅÆúʹÓÃË÷Òý¶ø½øÐÐÈ«±íɨÃè¡£È磺
select id from t where num/2=100
Ó¦¸ÄΪ:
select id from t where num=100*2
9.Ó¦¾¡Á¿±ÜÃâÔÚwhere×Ó¾äÖжÔ×ֶνøÐк¯Êý
²Ù×÷£¬Õ⽫µ¼ÖÂÒýÇæ·ÅÆúʹÓÃË÷Òý¶ø½øÐÐÈ«±íɨÃè¡£
È磺
select id from t where substring(name,1,3)=’abc’–nameÒÔabc¿ªÍ·µÄid
select id from t where
datediff(day,createdate,’2005-11-30′)=0–‘2005-11-30’Éú³ÉµÄid
Ó¦¸ÄΪ:
select id from t where name like &lsquo


Ïà¹ØÎĵµ£º

Now it's MySQL's turn...

Some problems encounted this afternoon, when trying to setup/test mysql capabilities on hypnos and virgil.
1.ERROR 2003 (HY000): Can't connect to MySQL server on 'server-name' (111)
access locally (i.e. from localhost) is fine, when trying remotely got this error. when tried with mysql++ library, ......

MysqlÊý¾Ý¿â±íÃû¿Õ¸ñ´¦Àí

½ñÌìʹÓÃPowerDesigner´î½¨ÁËÒ»¸öСÏîÄ¿£¬×îºóÖ´ÐÐÍêSQL½Å±¾Ê±²Å·¢ÏÖÓÐ2ÕűíµÄ±íÃûÖмä¶àÁËÒ»¸ö¿Õ¸ñ£¬²éÍê×ÊÁÏ£¬×îºó²¢¾ªÆæ·¢ÏÖÓ³ÉäÎļþ¾¹È»¶àÁË2¸ö`,¾ÍÊÇshift+Êý×Ö¼ü1µÄÄǸö£¬Ò²¾ÍÊÇËûÔڽű¾ÊÇÕâÑùдµÄ£º
create table `table1`(....);
ÎÊÌâ½â¾ö¡£
PS:´ÓÍøÉÏÕÒµ½µÄ×ÊÁÏ£º
×÷Ϊһ¸öOracle DBA£¬MySQLºÜ¶àSQLÓï·¨ÓëOrac ......

mysql´æ´¢¹ý³Ì Àý×Ó Óαêcursor Ñ­»·Ç¶Ì× ÊÂÎï

×òÌìÒªmysqlÖÐд´æ´¢¹ý³Ì·¢ÏÖÍøÉÏÓйØÓÚcursorÑ­»·ÇÒÌ×µÄ×ÊÁϺÜÉÙ,ÏÖ·¢³ö±¾ÈËдµÄÀý×Ó,Ï£ÍûÄܶԴó¼ÒÓаïÖú.
¿´ÕÐ:
DELIMITER $$
USE `ad_db`$$
DROP PROCEDURE IF EXISTS `test`$$
CREATE DEFINER=`root`@`%` PROCEDURE `test`()
BEGIN
     /** CPAЧ¹ûÊý */
DECLARE _tmpId1 INT; 
DECLARE ......

mysql´æ´¢¹ý³Ìtips

ʾÀý£º
create procedure proc_name (in parameter integer)
begin
declare variable varchar(20);
if parameter=1 then
set variable='MySQL';
else
set variable='PHP';
end if;
insert into tb (name) values (variable);
end; 
MySQLÀ©Õ¹Ò²ÊÇÖ§³Ö´æ´¢¹ý³ÌµÄ£¬²»¹ýÖ»Ö§³ÖÎÞ·µ»Ø½á¹ûµÄ´æ´¢¹ý³Ì
¿ÉÒÔÊ¹Ó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ