Easy-to-Forget SQL statement writing

Source: Internet
Author: User
1. Process date data
Select * from subject where pubtime >=# 01/01/2005 #

2. "*" is used in access to replace "%" in standard SQL ".

3. "_" represents a single character
Select * from users where name like '__'

4. The having clause allows you to specify conditions for each group, following the group by clause.
Select username, count (*)ArticleQuantity
From subject
Group by username
Having username in ('admin', 'flyer ')

5. calculate mathematical expressions
Select 5 + 6*10 + 10.5/23-(35-3)/90 as result

6. For the parameter SQL Server, use "@ parameter name", while oledb uses "?", When adding parameters to the oledbcommand object, the order must be the same as that defined in the SQL command.
Strsql = "select count (*) from orderclient where clientid =? ";

7. case statement
select au_fname, au_lname,
case state
when 'CA' then 'california '
when 'K' then 'Kansas'
when 'tn 'then' Tennessee '
When 'or 'then' Oregon'
when 'mi 'then' Michigan '
When' in 'then' Indiana '
when 'md 'then' maryland '
when 'ut' then 'utah'
end as statename
from pubs. DBO. authors
order by au_lname

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.