_1 start learning SQL database

Began to write SQL, after all, wait until school machine, it is a little late

Website: http://www.xuesql.cn

Previously the above table

And then on the issue

Although this problem is actually quite simple knowledge is also involved in several of

First

  SELECT * // select all columns, select both tuples out

  FROM Movies

Then, according to the director he added the title name in ascending order, if the director were the same press descending Year

See here, I deceived, what ,,? Because this usage eh mother in this site in

So I wrote a wiseacre

  SELECT *

  FROM(

  SELECT *........)

Really did not expect to be able to write, but I was the first name of the director to sort, and then row for years, it is in accordance with the format above,

Predictably, absolutely wrong chanting,

Because the title is the name of the director say the same year only came

Fortunately, I went wit a rookie look, there is the god of notes

So I know this write up is simple

ORDER BY Director ASC,Year DESC

(In line with the requirements of title above)

Then it is

LIMIT 10

So get away myself

Overall, that is,

SELECT,ORDER BY,LIMIT

Not useful OFFSET, and WHERE

Wherein WHERE condition is woven, such as WHERE id = 6

LIMIT 1 OFFSET 2

 

Guess you like

Origin www.cnblogs.com/WildSky/p/11544457.html