SQL learning
Five basic search conditions are summarized here:
1) Comparison test
2) Range test
3) Set membership test
4) Pattern matching test (Like)
The pattern matching test checks to see whether the data value in a column matches a specified pattern
% mathes any sequence of zero or more characters.
_ matches any single character.
// Find products whose product IDs start with the four letters "A%BC"
SELECT order_num ,product
from orders
WHERE product LIKE 'A$%BC' ESCAPE '$' ;
5) Null value test (IS NULL)
In SQL's three-valued logic, a search condition can yield a TRUE,FALSE, or NULL result. Only rows where search codition yields a TRUE result are included in the query result.
Rules For Single-Table Query Processing
The from clause is applied first; the where clause is applied next ; the SELECT clause is applied next . Finally, the
ORDER BY clause is applied to sort the query results.
相关文档:
Microsoft Access 数据类型
数据类型
描述
存储
Text
用于文本或文本与数字的组合。最多 255 个字符。
Memo
Memo 用于更大数量的文本。最多存储 65,536 个字符。
注释:无法对 memo 字段进行排序。不过它们是可搜索的。
Byte
允许 0 到 255 的数字。
1 字节
Integer
允许介于 -32,768 到 32 ......
在Where子句中,可以对datetime、char、varchar字段类型的列用Like子句配合通配符选取那些“很像...”的数据记录,以下是可使用的通配符:
% 零或者多个字符
_ 单一任何字符(下划线)
\ 特殊字符
[] 在某一范围内的字符,如 ......
说到软解析(soft prase
)和硬解析(
hard prase
),就不能不说一下
Oracle
对
sql
的处理过程。当你发出一条
sql
语句交付
Oracle
,在执行和获取结果前,
Oracle
对此
sql
将进行几个步骤的处理过程:
1、语法检查(
syntax check
)
&nb ......
(1) 选择最有效率的表名顺序(只在基于规则的优化
器中有效):
Oracle
的
解析器按照从右到左的顺序处理from子句中的表名,from子句中写在最后的表(基础表 driving
table)将被最先处理,在from子句中包含多个表的情况下,你必须选择记录条数最少的表作为基础表。假如有3个以上的表连接查询,
那就 ......
问题一
有这样的一个问题,数据库中有两个表,分别是Guest,Hotel,即旅客信息表和旅馆信息表,Guest表中有一个旅客编码的字段,这个字段的有20位,它的前10位代表这个旅客所住的旅馆,现在的问题是要根据Guest表中的旅客编码字段信息查到他所住的旅馆的名称和旅馆地址!
问题解决:
SQL SERVER的SQL语句:select ......