This article assumes that the reader has an understanding of the database connectivity technology, so only the syntax for SQL query commands is discussed.
The table structure is as follows (MS Access 2000):
Table Name: usertable
----------------------
Field Name segment type
----------------------
UserID Automatic counting (Long Integer)
UserName text
Usersex text
CreateDate Date/Time (default value is now ())
----------------------
First, use the Select command to extract the record
1. Get all the records in the table
Select command with the following statement:
"Select *from usertable"
2, get the table userid field records
"Select UserID from Usertable"
3, get the table userid, usersex Field Records
"Select UserID, usersex from Usertable"
4, to obtain the table Usersex value is "male" record
"Select from usertable Where usersex = ' Male '"
5. Take the record of the username value in the table containing the word "Zhang"
"Select from Usertable Where userName like '% man% '"
6, get all the records in the table, by CreateDate field value descending order
"Select from Usertable Order by CreateDate DESC"
Description
1, the above commands can be combined to use, such as, to obtain the username in the table containing the word "Hao", UserID value, and in descending order by the CreateDate value of time, then the order is as follows:
"Select UserID from usertable Where userName like '% Hao% ' order by CreateDate DESC"
2), in use should be noted that if the field type is text, then when the condition is discriminant, should be in the conditional word outside the single quotation mark, this rule applies to any one SQL query command.
3), the "%" in the conditional word is the wildcard character.
4), when the discriminant condition more than one, should be connected with "and" or "or".
Inserting new records with INSERT INTO command
1. Insert a new record
"Insert into Usertable (UserName, Usersex) Values (' Zhang Haonan ', ' Men ')"
Description
Note here that the type of the value of the inserted record should conform to the field type in the table, or else an error will occur. In fact, using single quotes is a convenient method, but not specification, because if the record you want to insert contains single quotes, there will be an error (although this does not happen frequently, it may be possible). So we'd better use a custom function to implement the single quote substitution. Methods are as follows
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service