Use SQL statement 1 in ASP: select statement

Source: Internet
Author: User
Use SQL statement 1 in ASP: select statement
Source: dns99.cn
There are so many SQL products that you may have to worry about. However, if you want to use ASP and SQL at the same time, you may feel dizzy. MySQL, SQL Server, and msql are both excellent SQL tools. Unfortunately, in the ASP environment, you do not need them to create practical SQL statements. However, you can use your access knowledge and corresponding access skills, coupled with our tips and skills, I believe you will be able to successfully add SQL to your asp web page.

In the world of SQL, the most basic operation is the SELECT statement. When using SQL directly using database tools, many people will be familiar with the following operations:

Select what

From whichtable

Where criteria

Execute the preceding statement to create a query that stores the result.

On the ASP page file, you can also use the above general syntax, but the situation is slightly different. during ASP programming, the content of the SELECT statement should be assigned to a variable as a string:

SQL = "select what from whichtable where criteria"

Now, I understand the way SQL is "spoken" in ASP. The next step is the method. As long as you meet your needs, the traditional SQL query mode and conditional query can be used smoothly.

For example, assume that your database has a data table named products. Now you want to retrieve all the records in this table. Then you write the following code:

SQL = "select * from products"

The preceding code -- SQL statement is used to retrieve all the data in the table. After execution, all records in the data table are selected. However, if you only want to retrieve a specific column from the table, such as p_name. Then you cannot use the * wildcard. enter the name of a specific column. The Code is as follows:

SQL = "select p_name from products"

After the above query is executed, all content in the p_name column in the products table will be selected.

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.