Using the 1:select Statement of SQL statements in ASP

Source: Internet
Author: User
select| statements |select a wide variety of SQL products, you may have done it sooner than others. But you can get dizzy if you want to use both ASP and SQL at the same time. MySQL, SQL Server, and msql are excellent SQL tools, but unfortunately you don't need them to create a useful SQL statement in an ASP environment. However, you can take advantage of your knowledge of access and the corresponding access skills, plus our tips and tricks, and believe that you will be able to successfully add SQL to your ASP pages.



In the SQL world, the most fundamental operation is the SELECT statement. When using SQL directly under Database Tools, many people will be familiar with the following: SELECT what
From whichtable
WHERE criteria

Executing the above statement creates a query that holds its results.

In the ASP page file, you can also use the above general syntax, but the situation is slightly different, ASP programming, the contents of the SELECT statement to be assigned as a string to a variable: SQL = "Select what from whichtable WHERE criteria"

OK, understand the ASP under the SQL "speak" way, then follow the same pattern, as long as you meet your needs, the traditional SQL query mode and conditional query can be useful.

For example, suppose you have a data table in your database, the name is products, and now you want to take out all the records in the list. Then you write the following code:
SQL = "SELECT * FROM Products"

The function of the above code--SQL statement is to take out all the data in the table--after execution, all the records in the datasheet will be selected. However, if you only want to remove a specific column from the table, such as P_name. Then you can't use the * wildcard character, you have to type the name of a specific column, the code is as follows:
SQL = "Select P_name from Products"

After executing the above query, the contents of the Products table and the P_name column will be all selected.



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.