Intro

作者: 腾子_Lony | 来源:发表于2017-08-26 08:57 被阅读0次

SQL, which stands forStructured Query Language, is a language for interacting with data stored in something called arelational database.

Each row, or record, of a table contains information about a single entity. For example, in a table representing employees, each row represents a single person. Each column, or field, of a table contains a single attribute for all rows in the table. For example, in a table representing employees, we might have a column containing first and last names for all employees.

In SQL, you can select data from a table using a SELECT statement. For example, the following query selects the name column from the people table

In the real world, you will often want to select multiple columns. Luckily, SQL makes this really easy. To select multiple columns from a table, simply separate the column names with commas!

For example, this query selects two columns,name and birthdate, from thepeopletable:

Sometimes, you may want to select all columns from a table. Typing out every column name would be a pain, so there's a handy shortcut:

SELECT *

FROM people;

If you only want to return a certain number of results, you can use the LIMIT keyword to limit the number of rows returned:

SELECT *

FROM people

LIMIT 10;

Often your results will include many duplicate values. If you want to select all the unique values from a column, you can use the DISTINCT keyword.

This might be useful if, for example, you're interested in knowing which languages are represented in thefilmstable:

SELECT DISTINCT language

FROM films;

What if you want to count the number of employees in your employees table? The COUNT statement lets you do this by returning the number of rows in one or more columns.

For example, this code gives the number of rows in thepeopletable:

SELECT COUNT(*)

FROM people;

As you've seen, COUNT(*) tells you how many rows are in a table. However, if you want to count the number of non-missing values in a particular column, you can call COUNT on just that column.

It's also common to combine COUNT with DISTINCT to count the number of distinct values in a column.

相关文章

  • Intro

    希望通过这个软件每天做一点记录,类似小日记吧,可能无聊或琐碎的这些点滴构成了我的生活^_^

  • Intro

    太漫长了 相当于 长出一根犀牛角的时间 在你不断对我说着话时 泡沫们跃升着 我的眼中口中开满了花 所有的泪水和话语...

  • Intro

    本人名“悦”,金牛座,性格实在活脱的不像人类。 因重视生命起源,想尝试摆脱各种人类局限,于是喜欢画一些“受精卵”磨...

  • Intro

    大家好啊,我是Tonia。Full stake designer。

  • 《The intro》

    我好不容易离开了忙碌,远离了人海,避开了聒噪,走进了你的世界,却又发现我已经再也睁不开疲乏的双眼,挥不动思想的笔触...

  • Intro

    这首歌真的很适合一大早没有人, 然后自己很拉风地路跑, 感觉整个世界都是自己的!! 有时候 ,我真的不喜欢热闹, ...

  • Intro

    (Optional) Create virtual environment prefer using python...

  • Intro

    As my return flight was making its initial landing attemp...

  • Intro

    敏捷教练,CSP,CSM。有13年软件开发经验,为团队提供敏捷教导和培训服务。他的使命是:和程序员一起重新点燃编程...

  • Intro

    SQL, which stands forStructured Query Language, is a lang...

网友评论

      本文标题:Intro

      本文链接:https://www.haomeiwen.com/subject/kolmdxtx.html