Considerations for using and and or in ASP's SQL statements-application tips

Source: Internet
Author: User

Today in the debugger, need to use and OR, if not mastering the skills output of the structure and we think that the gap is a bit large, here to share, I hope you will support the cloud Habitat community

Can and and or are not used concurrently in an ASP's SQL statement?

The answer is yes, let's look at the following method:

1, very responsible to tell you, can be used at the same time. But look at the business requirements

2, the use of the scene for example:

Query Table male students born in 2000 and 2002
SELECT * FROM student table where sex = ' male ' and (year of birth =2000 or year of birth =2002)
3, in fact, or can be replaced with SQL in, so that writing will be more convenient


For example, the above example is written in:
SELECT * FROM student table where sex = ' man ' and year of birth in (2000,2002)

In fact, it is through () to the need to pay attention to the place, expand the

For example: Cloud Habitat Community Background search, need to judge when the search is JS, then some of our editors use JavaScript, then some things can not search, then you can refer to this method

Core code:

Select Case LCase (Keyarr (i)) case
         "JS"
         sqlk=sqlk& "and (title like '%" &keyarr (i) & '% ' or title like '% javascript% ') "Case
         " JavaScript "
         sqlk=sqlk&" and (title like '% "&keyarr (I) &"% "or title like '%js% ' "Case     
         " C # "
         sqlk=sqlk&" and (title like '% "&keyarr (I) & '% ' or title like '%csharp% ')" Case
         " CSharp "
         sqlk=sqlk&" and (title like '% "&keyarr (I) &"% ' or title like '%c#% ') "Case
		 else
		 sqlk= sqlk& "and title like '%" &keyarr (I) & "%" "" 

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.