to Country (Id,name) VALUES (9, ' central America INSERT into country (id,name) VALUES ("Island Nations"), insert into country (id,name) values (one, ' one states '); SERT into country (id,name) VALUES ("Alabama"), insert into country (id,name) VALUES ("Alaska"), insert into country ( Id,name) VALUES ("Arizona"), insert into country (id,name) VALUES ("Arkansas"), insert into country (id,name) VALUES ( ' California ');--Table Country_relation.insert i
for var inch List Do CommandsdoneIn each iteration, the variable var contains the current value in the list, the first iteration uses the first value in the list, and the second one uses the second value.In do and done, the $var variable contains the current value corresponding to this iteration.You can put the do statement and the FOR statement on the same line as long as you want, but you must separate it from the values in the list with a semicolon. for Var in list;do.#! /bin/bash for in
country (id,name) VALUES (8, ' Canada '); Insert to Country (Id,name) VALUES (9, ' central America INSERT into country (id,name) VALUES ("Island Nations"), insert into country (id,name) values (one, ' one states '); SERT into country (id,name) VALUES ("Alabama"), insert into country (id,name) VALUES ("Alaska"), insert into country ( Id,name) VALUES ("Arizona"), insert into country (id,name) VALUES ("Arkansas"), insert into country (id,name) VALUES (
stored procedure to implement similar ORACLE analysis functions.
In this way, create a simple data table.
create table country ( id number(2) not null, name varchar(60) not null);create table country_relation (id number(2), parentid number(2));
Insert some data
-- Table country.insert into country (id,name) values (0,'Earth');insert into country (id,name) values (2,'North America');insert into country (id,name) values (3,'South America');insert into country (id,name) values (4,'Europe');ins
into country (id, name) values (9, 'Central America '); insert into country (id, name) values (10, 'island Nations'); insert into country (id, name) values (11, 'United States'); insert into country (id, name) values (12, 'alabama'); insert into country (id, name) values (13, 'alaska '); insert into country (id, name) values (14, 'arizona '); insert into country (id, name) values (15, 'arkansas'); insert into country (id, name) values (16, 'californi
efficient. This allows the database engine to discover that only 1 will stop the scan, rather than scan the entire table or index.
Copy Code code as follows:
Do I have any of the users from Alabama?
What does:
$r = mysql_query ("SELECT * from user WHERE state = ' Alabama '");
if (mysql_num_rows ($r) > 0) {
// ...
}
Much better:
$r = mysql_query ("Select 1 from user WHERE state
, adding a limit of 1 will make your query more efficient. This allows the database engine to discover that only 1 will stop scanning, rather than scanning the entire table or index. 1.//Does I have any users from Alabama? 2.//What isn't to do:3. $r = mysql_query ("SELECT * from user WHERE state = ' Alabama '"); 4. if (mysql_num_rows ($r) > 0) {5.//... 6.} 7. Much better:8. $r = mysql_query ("Select 1 from
Island58. Case Western Reserve Univ59. Auburn University60. University of Illinois at Chicago61. Colorado State University62. Oregon State University63. Texas at arington64. pitt0000gh65. Duke University66. University of Tennessee-Knoxville67. Lehigh University68. Naval Postgraduate School69. Texas Tech University70. George Washington University71. vandrebilt University72. University of Kansas73. Clemson University74. Clarkson University75. New Mexico State University76. Southern Methodist Univ
index.Copy CodeThe code is as follows:Does I have any users from Alabama?What isn't to do:$r = mysql_query ("SELECT * from user WHERE state = ' Alabama '");if (mysql_num_rows ($r) > 0) {// ...}Much better:$r = mysql_query ("Select 1 from user WHERE state = ' Alabama ' LIMIT 1");if (mysql_num_rows ($r) > 0) {// ...}4. Retrieving fields in the indexAn index is not
, or just check the number of records that exist, and they all satisfy your WHERE clause.
In this case, adding a limit 1 will make your query more efficient. This allows the database engine to discover that only 1 will stop the scan, rather than scan the entire table or index.
1.//do I have any of the users from Alabama?
2.//What DO:
3. $r = mysql_query ("SELECT * from user WHERE state = ' Alabama '");
the entire table or index.1.//do I have any of the users from Alabama?2.//What DO:3. $r = mysql_query ("SELECT * from user WHERE state = ' Alabama '");4. if (mysql_num_rows ($r) > 0) {5.//...6.}7.//Much better:8. $r = mysql_query ("Select 1 from user WHERE state = ' Alabama ' LIMIT 1");9. if (mysql_num_rows ($r) > 0) {10.//...11.}
4 4. Retrieved fields in the
, rather than scan the entire table or index.
Copy Code code as follows:
Do I have any of the users from Alabama?
What does:
$r = mysql_query ("SELECT * from user WHERE state = ' Alabama '");
if (mysql_num_rows ($r) > 0) {
// ...
}
Much better:
$r = mysql_query ("Select 1 from user WHERE state = ' Alabama ' LIMIT 1");
if (mysql_num
.//Do I have any users from Alabama? 2.//What does not have: 3. $r = mysql_query ("SELECT * from user WHERE state = ' Alabama '"); 4. If (mysql_num_rows ($r) > 0) { 5.//... 6.} 7.///Much better: 8. $r = mysql_query ("Select 1 from user WHERE state = ' Alabama ' LIMIT 1"); 9. If (mysql_num_rows ($r) > 0) { 10.//... One.} 12. Do not use the by RAND () comm
scanning after 1, instead of scanning the entire table or index. ,
1. // do I have any users from Alabama?
2. // what NOT to do:
3. $ r = mysql_query ("SELECT * FROM user WHERE state = Alabama ");
4. if (mysql_num_rows ($ r)> 0 ){
5 .//...
6 .}
7. // much better:
8. $ r = mysql_query ("SELECT 1 FROM user WHERE state = Alabama LIMIT 1 ");
9. if (mysql_num_rows ($
? "We can never be satisfied as long as the Negro is the victim of the unspeakable horrors of police brutality. we can never be satisfied as long as our bodies, heavy with the fatigue of travel, cannot gain lodging in the motels of the highways and the hotels of the cities. we cannot be satisfied as long as a Negro in Mississippi cannot vote and a Negro in New York believes he has nothing for which to vote. no, no, we are not satisfied and we will not be satisfied until justice rolls down like w
. The rule of thumb is multiplied by the number of columns of all "rows", your query performance will be proportional to the number of results.
3. Use limit 1 to get unique rows
Sometimes when you look up a table, you already know that the result you are looking for is only one line. You may be getting a unique record, or you may just be querying for a record that satisfies the condition of your WHERE clause.
In this case, adding limit 1 to the query condition can improve performance. This wa
PHP array {array} use Tutorial
Now, this lengthy setting uses a set of methods for each attribute-there must be a simpler way. This is the associative array that comes in handy with our constructs. Let's create our user object and give it a few instances when performance
$attribs = Array (' Name ' => ' Kirupa ',' Job ' => ' Engineer ',' School ' => ' MIT ',' Hometown ' => ' Spanish Fort ',' Homestate ' => ' Alabama ');$kirupa = new User ($attrib
positions, and the technical knowledge or quality required for these jobs. Determine the confidence in your career and see what options you may have in the software industry. In your software career, you may encounter various job opportunities. The development of each job varies with the characteristics or personality of each person. For the ever-changing IT industry, it is helpful to determine the target and plan in advance.While introducing each type of job, we will learn about some common to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.