For MySQL, the first thing you must keep in mind is that each line of its commands ends with a semicolon (;), but when a line of MySQL is inserted in the PHP code, the most I will omit the following semicolon, for example: mysql_query("INSERT INTO tablename(first_name,last_name)VALUES('$first_name',$last_name')"); This is because PHP also ends with a semicolon as a line The extra semicolon sometimes makes PHP's parser incomprehensible, so it's better to omit it. In this case, although the semicolon is omitted, PHP will automatically add it to you when you execute the MySQL command. Use the associative array to access the query results to see the following example: $connection=mysql_connect("localhost","albert","shhh");mysql_select_db("winestore",$connection);$result=mysql_query(" ;SELECT cust_id,surname,firstname FROM customer",$connection);while($row=mysql_fetch_array($result)){echo"ID:t{$row["cust_id"]n";echo"Surnamet{$ Row["surname"]}n";echo"First name:t{$row["firstname"]}nn";}function mysql_fetch_array() puts a row of the query result into an array, which can be used in two ways at the same time. References, such as cust_id, can be used in two ways: $row["cust_id"] or $row[0]. Obviously, the former is much more readable than the latter. In the multi-table continuous check, if the two columns have the same name, it is best to use the alias to separate them: SELECT winery.name AS wname, region.name AS rname, FROM winery, region WHERE winery.region_id=region.region_id; For: $row["wname"] and $row["rname"] in the case of specifying the table name and column name, only the column name is referenced: SELECT winery.region_idFROM winery column name reference is: $row[" The reference to the region_id"] aggregate function is the reference name: SELECT count(*) FROM customer; the column name reference is: $row["count(*)"] TEXT, DATE, and SET data type MySQL data table fields There must be a data type defined. There are about 25 choices, most of which are straightforward, and it doesn't take much. But there are a few that need to be mentioned. TEXT is not a data type, although it may be said in some books. It should actually be "LONG VARCHAR" or "MEDIUMTEXT". The format of the DATE data type is YYYY-MM-DD, for example: 1999-12-08. You can easily use the date function to get the current system time in this format: date("Ym-d") and, in the DATA data type, you can subtract, get the difference in the number of days: $age=($ Current_date-$birthdate); Collection SET is a useful data type that is somewhat similar to enumerating ENUM, except that SET can hold multiple values and ENUM can only hold one value. Moreover, the SET type can only have a maximum of 64 predetermined values, while the ENUM type can handle up to 65,535 predefined values. And if you need a collection with more than 64 values, what should you do? You need to define multiple collections to solve the problem together. Using mysql_unbuffered_query() to develop a fast script This function can be used to replace the mysql_query() function. The main difference is that mysql_unbuffered_query() returns immediately after executing the query, without waiting or locking the database. However, the number of rows returned cannot be checked with the mysql_num_rows() function because the output result set size is unknown. Wildcard SQL has two wildcards: “*” and “%”. Used in different situations. For example, if you want to see all the contents of the database, you can query it like this: SELECT*FROM dbname WHERE USER_ID LIKE '%'; here, both wildcards are used. They mean the same thing?? They are used to match any string, but they are used in different contexts. “*” is used to match field names, and “%” is used to match field values. Another area that is not easy to draw attention to is the "%" and "wildcards" need to be used with the LIKE keyword. There is also a wildcard, the underscore “_”, which means something different from the above, is used to match any single character. NOT NULL and empty records What happens if the user presses the submit button without filling anything? If you do need a value, you can use client-side scripting or server-side scripting for data validation. However, in the database, some fields are allowed to be vacant and nothing is filled. For such records, MySQL will do something for it: insert the value NULL, which is the default action. If you declare NOT NULL in the field definition (when creating or modifying this field), MySQL will leave this field blank and leave nothing. For a field of type ENUM enumeration, if you declare NOT NULL for it, MySQL will insert the first value of the enumeration set into the field. That is, MySQL uses the first value of the enumeration set as the default value for this enum type. There is some difference between a record with a value of NULL and an empty record. The % wildcard can match an empty record, but it does not match a NULL record. At some point, this difference can have some unintended consequences. As far as my experience is concerned, any field should be declared NOT NULL. So many SELECT queries will work. Note that when searching for NULL, you must use the “IS” keyword, and LIKE will not work properly. The last thing to mention is that if you have some records in the database before adding or modifying a new field, the value of the newly added field in the original record may be NULL or it may be air. This is also a bug in MySQL, so in this case, use SELECT queries with special care. Xiaobian recommended: PHPMyAdmin (MySQL database management) official latest version download this article from [system home] www.xp85.com