`

Basic SQL: Where, Order by,Comparision and Logical Conditions

阅读更多
http://superman-chenzs.itpub.net/post/29327/273849

SELECT *|{[DISTINCT] column|expression [alias],...}
FROM table
[WHERE condition(s)]
[ORDER BY Clause];


Limiting the Rows Selected
* Restrict rows returned by using the WHERE clause.


-----------------------------------------------------------------------------------------------------------------
Character Strings and Dates
- Character strings and date values are enclosed in single quotation marks
- Character values are case sensitive,and date values are format sensitive
- The default date formate is DD-MON-YY


------------------------------------------------------------------------------------------------------------------
Comparision Conditions
= : equla to
> : greater than
>= : greater than or equal to
< : less than
<= : less than or equal to
<> : not equal to

BETWEEN ... AND ... : between two values (inclusive)
IN (SET) : Match any of a list of values
LIKE : Match a character pattern
IS NULL: Is a null value
IS NOT NULL : Is not a null value


Using the LIKE Condition : Pattern-Matching
- Use the LIKE condition to perform wildcard searches of valid search string values
- Search conditions can contain either literal characters or numbers:
1. % denotes zero or many characters
2. _ denotes one characters
- You can combine pattern-matching characters
- You can use the ESCAPE identifier to search for the actual % and _ symbols


------------------------------------------------------------------------------------------------------------------
Logical Conditions
AND : Returns TRUE if both component conditions are true
OR : Returns TRUE if either component condition is true
NOT : Returns TRUE if the following condition is false (Before other keywords, eg: not like)


------------------------------------------------------------------------------------------------------------------
Rules of Precedence
1 -> Arithmetic operators
2 -> Concatenation operator
3 -> Comparison conditions
4 -> IS [NOT] NULL,[NOT] LIKE,[NOT] IN
5 -> [NOT] BETWEEN...AND...
6 -> NOT logical condition
7 -> AND logical condition
8 -> OR logical condition
Override rules of precedence by using parentheses


------------------------------------------------------------------------------------------------------------------
ORDER BY Clause
1.Sort rows with the ORDER BY clause
- ASC: ascending order,default
- DESC: descending order
2.The ORDER BY clause comes last in the SELECT statement
3.The order of ORDER BY list is the order of sort
4.You can sort by a column that is not in the SELECT list
5.You can sort by a column by using the alias name
分享到:
评论

相关推荐

    Absolute Database for D7

    logical, date-time and string functions and operators Data types conversion by function CAST SQL scripts (multiple commands separated by ‘;‘) Parameters in queries SELECT from several databases in ...

    MySQL命令大全

    mysql&gt; select * from MyClass order by id limit 0,2; 或者: mysql&gt; select * from MyClass limit 0,2; 6、删除表中数据 命令:delete from 表名 where 表达式 例如:删除表 MyClass中编号为 的记录 mysql&gt;...

    Comparision of MODTRAN and FASCODE

    Mazuk和***nch编写的,属于Space Science Applications Laboratory,为Space and Missile Systems Center进行的一项研究,报告是在美国空军物资司令部的批准下发布的,并且对公众开放。这项研究得到了The Aerospace...

    android-app-size-diff:在您的CI中衡量的Android应用大小

    介绍 该存储库包含一个和一个 。 请参阅以下用法示例以在CI中开始使用它。... displayName : Run APK size comparision 在GitHub工作流程中 - uses : microsoft/android-app-size-diff@v0.32 name : Run

    duckql-python:基于JSONSQL表示库

    鸭QL :front-facing_baby_chick: duckQL是基于库的某些SQL方言(PostgreSQL,MariaDB,MySQL)的基于JSON的简单表示法。... conditions = Comparision ( properties = [ Property ( name = 'use

    Suboptimal comparision_fixed_matlab_

    "Suboptimal Comparison of AF and DF Relaying For Fixed Target Error Probability" 这个研究主题聚焦于比较两种常见的中继策略:放大转发(Amplify-and-Forward, AF)和解码转发(Decode-and-Forward, DF),在...

    max-min-comparision-block.rar_operation

    在LabVIEW编程环境中,Max_MIN操作是数据处理和分析中常用的一种功能,它涉及到数值比较..."max-min comparision block.vi"文件提供了一个具体的实现案例,用户可以通过打开、学习和修改这个VI来深化对这一概念的理解。

    css-reset-comparision:CSS重置比较-不加考虑CSS重置和规范化比较

    css-reset-comparision是一个很棒CSS重置比较。 对于任何网页设计师来说,这都是一个很好的资源。 css-reset-comparision比较所有重置和规范化器。 目录 执照 地位 比较 归一化器 体裁 normalize.css 现代规范...

    [MMS_040328]Data Comparision of value in array files.rar

    本资料 "[MMS_040328]Data Comparision of value in array files" 可能是关于如何在AB PLC环境中进行数组内数值的比较和分析的教程或实例。 1. **数组基础知识**:在AB PLC(Allen Bradley PLC,罗克韦尔自动化公司...

    LQRu1.rar_PI_comparision_controller_pi controller

    pi controller design and its comparison with advanced controller

    Computational Comparision of serval CG methods

    标题中的"Computational Comparison of several CG methods"表明这是一个关于比较几种不同的共轭梯度(CG)方法的计算研究。描述中提到的“modified four-term extension of the Dai-Liao conjugate gradient method”...

    java实现算法

    Java 实现算法 本文档将对 Java 实现的四种算法进行详细的分析和解释,包括冒泡排序、选择排序、插入排序和 Rank 排序。每种算法都将从思想、实现、复杂度分析三个方面进行详细的介绍。 冒泡排序 ...

    A Comparison of SIFT, PCA-SIFT and SURF.ppt

    A Comparison of SIFT, PCA-SIFT and SURF.ppt

    COMPARISION.rar_OCCH_mclt_wireless networks

    Comparison of OCCH Critical,OCCH Randomness and MCLT algorithm in terms of performance parameters for Wireless sensor networks in Matlab

    串口调试程序

    串口调试程序

    Oops-Line-Comparision

    在Java编程语言中,"Oops-Line-Comparision"可能指的是面向对象编程(Object-Oriented Programming,简称OOP)中的一个重要概念,即类与类之间的关系比较。在本项目或教程中,可能通过代码行的对比来分析和理解不同...

    model_comparision:查找RMSE值并比较两个模型的代码

    在这个"model_comparision"项目中,我们聚焦于通过评估RMSE(均方根误差)来比较两个模型。RMSE是一种常用的度量标准,用于衡量预测值与真实值之间的差距。 RMSE是通过计算每个数据点的预测误差的平方,然后取平均...

    LS_MMSE_SMMSE_SER_Comparision.rar_MMSE LS_MMSE comparison_SMMSE_

    标题中的"LS_MMSE_SMMSE_SER_Comparision.rar"暗示了一个关于线性最小均方误差(Least Squares, LS)、最小均方误差(Minimum Mean Square Error, MMSE)以及改进型最小均方误差(Simplified Minimum Mean Square ...

    nation_wide_mobility_comparision:Twitter与多来源流动性调查在全国范围内的比较

    本项目,名为“nation_wide_mobility_comparision”,聚焦于利用Twitter数据与多源流动性调查进行全国范围内的比较分析。这种比较有助于我们更深入地理解人口流动模式,为政策制定者提供有力的数据支持。 首先,...

    Answer Set Solver Comparision Tool-开源

    标题中的“Answer Set Solver Comparision Tool”是一款专门用于对比不同答案集求解器性能的开源工具。答案集程序(Answer Set Programming, ASP)是一种强大的、声明式的编程范式,广泛应用于逻辑推理、人工智能和...

Global site tag (gtag.js) - Google Analytics