获取数据:
Select [options] items
[into file_details]
From tables
[ where conditions ]
[ group by group_type]
[ having where_definition ]
[ order by order_type ]
[ limit limit_criteria];
select ntitle,ncontent from news
select * from news
select * from news where nid = 2
select * from news where nid > 2
SELECT * FROM `news` WHERE ntitle LIKE "%12%"
Select * FROM `news` WHERE nid = 1 or nid =2
=和> …等where子句的实用比较运算符见表(P181)
= . > . < . <= >= !=(<>) between in . not in . like . not like . regexp(常规表达式)
联合查询:
union all(查出id为123345的一个表,重复字段显示):
select *
from student
where id < 4
union all
select *
from student
where id > 2 and id < 6
union(查出id为12345的一个表,重复字段不显示):
select *
from student
where id < 4
union
select *
from student
where id > 2 and id < 6