SQL Beginner Tutorial Learning (ii)

Source: Internet
Author: User
Tags aliases reserved

The 1.SQL statement selects the first two records from the Websites table:

SELECT * from Websites LIMIT 2;

< Span class= "Hl-code" >select TOP 50 PERCENT * from Websites

2. Wildcard characters

The A.SQL statement selects all Web sites with the URL beginning with the letter "https":

< Span class= "Hl-code" >select * from Websites
WHERE url like ' https% ' b.sql statement select name starts with an arbitrary character, then all customers with "Oogle"

SELECT * from Websites
WHERE name like ' _oogle ';

The C.SQL statement selects all Web sites that have the name start with "G", "F", or "s":

SELECT * from Websites
WHERE name REGEXP ' ^[gfs] ';

The D.SQL statement selects a Web site whose name begins with a to H letter:

SELECT * from Websites
WHERE name REGEXP ' ^[a-h] ';

The E.SQL statement selects a Web site whose name does not start with a to H letter:

SELECT * from Websites
WHERE name REGEXP ' ^[^a-h] ';

4. Aliases

SELECT name, CONCAT (URL, ', ', Alexa, ', ', country) as Site_info
From Websites;

5. "Websites" and "access_log" tables and specify table aliases "W" and "a" for each of them, respectively

SELECT W.name, W.url, A.count, a.date
From Websites as W, Access_log as a
WHERE A.site_id=w.id and W.name= "rookie Tutorial";

SQL Beginner Tutorial Learning (ii)

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.