For MySQL, the first thing you must remember is that every line of its command is ended with a semicolon (;), ...... The same is true here. When a line of MySQL is inserted into the PHP code, it is best to put the semicolon
For MySQL, the first thing you must remember is that every line of its command is ended with a semicolon (;), ...... The same is true here.
When a line of MySQL is inserted into the PHP code, it is best to omit the 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 may sometimes make PHP syntax analyzer confused, so it is better to omit it. In this case, the semicolon is omitted, but PHP will help you add it when executing the MySQL command.
There is also a case where no extra points are required. When you want to display the vertical arrangement of fields, rather than horizontal arrangement as usual, you can use G to end a line of SQL statements, then you will not use a semicolon, for example:
SELECT * FROM PENPALS
WHERE USER_ID = 1g text, DATE, and SET data type
A field in the MySQL data table must define a data type. There are about 25 options, most of which are directly clear, and there is little to worry about. But there are a few things to mention.
TEXT is not a data type, although it may be said in some books. It should actually be "long varchar" or "MEDIUMTEXT ".
The pattern of DATE data type is YYYY-MM-DD, for example:. you can easily use the date function to obtain the pattern of the current system Time:
Date ('Y-m-D ')
In addition, subtraction can be performed between DATA types to obtain the time difference days:
$ Age = ($ current_date-$ birthdate );
Clustering SET is a useful data type. it is similar to enumeration ENUM, except that SET can retain multiple values while ENUM can only keep one value. In addition, the SET type can have up to 64 predefined values, while the ENUM type can process up to 65,535 predefined values. What should we do if we need to have a cluster with more than 64 values? In this case, you need to define multiple aggregates to solve the title together.
Wildcard
There are two types of SQL configuration characters: "*" and "% ". Resolution is used in different cases. For example, if you want to view all the content of the database, you can query it like this:
SELECT * FROM dbname
WHERE USER_ID LIKE \ '% \';
Here, both wildcards are used. What do they mean in the same way ?? They are used to match any string, but they are used in different levels. "*" Is used to match the field name, while "%" is used to match the field value. Another concern is that the "%" wildcard must be used with the LIKE keyword.