whereÌõ¼þ¶Ômysql¶àÁÐË÷ÒýµÄʹÓÃ
MySQLÊÖ²áÖп´µ½µÄ£¬¼Ç¼Ï¡£
MySQL¿ÉÒÔΪ¶à¸öÁд´½¨Ë÷Òý¡£Ò»¸öË÷Òý¿ÉÒÔ°üÀ¨15¸öÁС£¶ÔÓÚijЩÁÐÀàÐÍ£¬¿ÉÒÔË÷ÒýÁеÄǰ׺(²Î¼û7.4.3½Ú£¬“ÁÐË÷Òý”)¡£
¶àÁÐË÷Òý¿ÉÒÔÊÓΪ°üº¬Í¨¹ýÁ¬½ÓË÷ÒýÁеÄÖµ¶ø´´½¨µÄÖµµÄÅÅÐòµÄÊý×é¡£
MySQL°´ÕâÑùµÄ·½Ê½Ê¹ÓöàÁÐË÷Òý£ºµ±ÄãÔÚWHERE×Ó¾äÖÐΪË÷ÒýµÄµÚ1¸öÁÐÖ¸¶¨ÒÑÖªµÄÊýÁ¿Ê±£¬²éѯºÜ¿ì£¬¼´Ê¹ÄãûÓÐÖ¸¶¨ÆäËüÁеÄÖµ¡£
¼Ù¶¨±í¾ßÓÐÏÂÃæµÄ½á¹¹£º
CREATE TABLE test (
id INT NOT NULL,
last_name CHAR(30) NOT NULL,
first_name CHAR(30) NOT NULL,
PRIMARY KEY (id),
INDEX name (last_name,first_name)
);
nameË÷ÒýÊÇÒ»¸ö¶Ôlast_nameºÍfirst_nameµÄË÷Òý¡£Ë÷Òý¿ÉÒÔÓÃÓÚΪlast_name£¬»òÕßΪlast_nameºÍfirst_nameÔÚÒÑÖª·¶Î§ÄÚÖ¸¶¨ÖµµÄ²éѯ¡£Òò´Ë£¬nameË÷ÒýÓÃÓÚÏÂÃæµÄ²éѯ£º
SELECT * from test WHERE last_name='Widenius';
SELECT * from test
WHERE last_name='Widenius' AND first_name='Michael';
SELECT * from test
WHERE last_name='Widenius'
AND (first_name='Michael' OR first_name='Monty');
SELECT * from test
WHERE last_name='Widenius'
AND first_name >='M' AND first_name < 'N';
È»¶ø£¬nameË÷Òý²»ÓÃÓÚÏÂÃæµÄ²éѯ£º
SELECT * from test WHERE first_name='Michael';
SELECT * from test
WHERE last_name='Widenius' OR first_name='Michael';
Ïà¹ØÎĵµ£º
½ñÌìÓöµ½Êý¾Ý¿âµÄÒ»¸öÎÊÌ⣬¾ÍÊÇÿµ±´ÓÖ÷±íÖÐɾ³ýÒ»¸öÖ÷¼üidʱ£¬ÓÉÓÚÓëËûÏà¹ØÁªµÄ±íÖÐÓÐÏà¹ØµÄ×Ö¶ÎÊý¾Ý£¬ËùÒÔÎÞ·¨É¾³ý¡£²éÁËÒ»´ó¶Ñ×ÊÁÏ£¬·¢ÏÖÎÒ½¨±í¹ØÁªÓõÄÊÇon Restrict.¿ÉÄÜÎÊÌâ¾Í³öÔÚÕâÀï°É¡£
Íâ¼üÔ¼Êø¶Ô×Ó±íµÄº¬Òå:
Èç¹ûÔÚ¸¸±íÖÐÕÒ²»µ½ºòÑ¡¼ü,Ôò²»ÔÊÐíÔÚ×Ó±íÉϽøÐÐinsert/update
Íâ¼üÔ¼Êø ......
×òÌ죬¹«Ë¾´Ó·þÎñÆ÷ÉϸãÏÂÀ´Ò»¸ö´óµÄÊý¾Ý¿â£¬Îļþ´óСΪ487MB£¬ÓÐͬÊÂ˵½«php.iniµÄÎļþÅäÖÃÖеÄpost_max_size¸ÄΪ±ÈÄãÒªµ¼ÈëµÄÊý¾Ý¿âÎļþ´óһЩµÄ£¬±ÈÈçÏÖÔÚÎÒÒªµÄµ¼ÈëµÄÊý¾Ý¿âÎļþÊÇ487MB£¬ÄÇô¿ÉÒÔ½«´ËÏî¸ü¸ÄΪ£º700MB£¬ÔÙʹÓÃphpMyAdmin¹¤¾ßµÄµ¼È빦ÄÜÀ´ÊµÏÖ£¬µ«ÊÇ£¬ÎÒÊÔÓÃÁË´ËÖÖ·½·¨²»ÄÜ×àЧ£¬È»ºóÓëÓоÑéµÄÅóÓѽ»Á÷£ ......
½ñÌìÔÚʵ¼Ê¿ª·¢ÖжÔÓÚMySQLÊý¾Ý¿â½øÐÐÒÆÖ²·¢ÉúµÄÎÊÌâÀ´ËµÏÂ. ¿ªÊ¼°Ñ±¾µØdataÖеÄÊý¾Ý¿âÎļþ¿½±´µ½Áíһ̨»ú×ÓÉÏTest, Ö´ÐÐshow tables ; ¿ÉÒÔ¿´µ½Êý¾Ý¿â±í,µ«ÊǶԱí½øÐÐÈκβÙ×÷¶¼±¨´í: ±í²»´æÔÚ , ÔÒÔΪMysqlµÄÊý¾Ý¿âÎļþ(.frm)Copy->stickµ½±¾µØ°²×°MySQLDBĿ¼µÄdataÎļþ¼ÐϾͿÉÒÔ.ÊÂʵ²»Ê ......
µ¼³ö
select field1,field2,field3 from tablename into outfile '/home/output1.csv' fields terminated by ','optionally enclosed by ''lines terminated by '\n';
µ¼Èë
load data local infile '/home/output1.csv' into table tablename fields terminated by ','lines terminated by '\n'(field1,f ......
ÏÈÇ°ÔÚ²âÊÔmysql connect c++½Ó¿ÚµÄʱºòÔËÐÐÆä¹Ù·½ÌṩµÄÀý×Ó
21.5.5.6. MySQL Connector/C++ Complete Example 2
The following code shows a complete example of how to use MySQL Connector/C++:
/* Copyright 2008 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify ......