查詢基礎以及資料庫的連線

2021-06-27 19:08:59 字數 1928 閱讀 4915

歡迎來到

unity學習

、unity培訓

、unity企業培訓

教育專區,這裡有很多

u3d資源

、u3d教程

、u3d常見問題

、u3d專案原始碼

,我們致力於打造業內

unity3d

培訓、學習第一品牌。

一、查詢基礎

--建立資料庫

create database class2

--使用資料庫

use class2

--建立表

create table student

--查詢表

select*from student

--查詢部分行

select name,password from student where id<>3

--命名列名並查詢

select id 學號,name 姓名,password 密碼 from student 

--為表新增一列

alter table student add age int null

--更改新新增列的屬性

alter table student alter column age varchar(10)

--刪除新新增的列

alter table student drop column age

--更新表中一條資料

update student set password=234 where name='張三'

--刪除表中一條資料

delete from student where name='張三'

--向表中插入一條資料

insert into student(name,password)values('王五',234)

--去掉重複字段查詢記錄

select distinct name from student

--合併查詢(合併兩表中相同的字段)

select*from student union select*from student3

--查詢非空行

select name from student where name is not null

--使用常量列

select 姓名=name,'密碼' password from student

--限制固定行數

select top 1 id,name,password from student where name='王五'

--返回百分比行數

select top 50 percent id,name,password from student where name='王五'

--排序

select id 學號,name 姓名,password 密碼

from student 

where password>111

--按多列排序

select id,name,password from student 

where name='王五'

order by password asc

二、連線資料庫

class program

myreader.close();

c.close();

}static void main(string args)}

三、插入功能

public int insert()

四、查詢功能

public listselect() 

listlist = select();

ienumeratorit = list.getenumerator();

while(it.movenext())

連線資料庫查詢基礎

public w3c dtd xhtml 1.0 transitional en 1.造連線物件 db new mysqli localhost 使用者名稱 密碼 要操作的資料庫 2.判斷鏈結是否出錯 if mysqli connect error 3.準備sql語句 sql select name...

MySql資料庫 資料庫的新建以及基礎查詢

mysql資料庫的基本操作 新建資料庫 creat database python test charset utf8 使用資料庫 use python test 建立學生表 creat table students id int unsigned primary key auto incremen...

資料庫連線查詢

一 交叉連線查詢 將第一張表的所有記錄分別與第二張表的每條記錄形成一條新的記錄。select 列名 from 表名1 cross join 表名2 二 內連線查詢 返回多個表中滿足連線條件的記錄 select 表名1.列名1 from 表名1 inner join 表名2 on 連線條件 selec...