查詢
select ··
from ··
where··
like··
between ·· and ··
as
條件查詢
and=“并”集合
or=“或”集合
in=“在···范圍內(nèi)”
##根據(jù)課程代號(hào)(code)查找所有可選的課程設(shè)置
SELECT
co.id 'course_id',
co.code 'course_code',
co.name 'course_name',
co.description 'course_description',
co.credit 'course_credir',
ct.id 'course_template_id',
ct.course_type_id ,
ct.create_datetime,
cf.id 'course_offered_id',
cf.class_capacity,
cf.class_remain,
cf.class_time
FROM
course_template ct,
course co,
course_offered cf
WHERE
cf.course_template_id = ct.id
AND ct.course_id = co.id
AND co.code = '數(shù)據(jù)庫(kù)'
and cf.class_remain >0;
插入語句
Insert into table( ···)
vlaues()
insert into student(id,firstname,lastname,phone,email,gender,age,student_status_id,accommodation_id,sid)values(2,'蕭','燚','15705799575','xy@sina.com','男',19,1,2,102);
更新語句
update (table···)
set ···
where ···
禁用安全更新
set sql_safe_updates =0;
開啟安全更新
set sql_safe_updates =1;
set sql_safe_updates=0;
UPDATE student
SET
student_status_id = 1
WHERE
gender = '男';
UPDATE teacher t
SET
t.firstname = '栗子',
t.lastname = '西'
WHERE
t.id = 4;
set sql_safe_updates=1;
排序
order by (用于對(duì)結(jié)果排序)··· desc 降序
order by (用于對(duì)結(jié)果排序)··· asc 升序
select* from student order by age asc;
select* from student order by sid desc;