當前位置:首頁 » 編程語言 » sql指令

sql指令

發布時間: 2022-01-14 06:10:22

1. sql命令語句

update 入貨單 set 貨物名稱=alltrim(thisform.text2.value),進貨價格=alltrim(thisform.text3.value),批發價=alltrim(thisform.text4.value),零售價=alltrim(thisform.text5.value) where 貨物名稱==alltrim(thisform.text1.value)

在sql語句中,裡面的值必須是數據,thisform.text2.value 是表單 上的內容,

在頁面上,通過構造sql字元串,然後
sql="update 入貨單 set 貨物名稱=alltrim(thisform.text2.value),進貨價格=alltrim(thisform.text3.value),批發價=alltrim(thisform.text4.value),零售價=alltrim(thisform.text5.value) where 貨物名稱==alltrim(thisform.text1.value)"
將字元串提交執行。

sql="update 入貨單 set 貨物名稱='"+alltrim(thisform.text2.value)+"',進貨價格="+alltrim(thisform.text3.value)+",批發價="+alltrim(thisform.text4.value)+",零售價="+alltrim(thisform.text5.value)+" where 貨物名稱='"+alltrim(thisform.text1.value)+"'"

通過上面語句將thisform.text2.value 內容嵌入到字元串中,然後提交即可。

你的錯誤,是提交的字元串中,類似於alltrim(thisform.text2.value)的數據在資料庫中是不存在的,如果將其換上它的內容就對了。

當然,按照sql規則,如果是字元格式,需添加''.

應該在你程序里添加一下語句,
sql="update 入貨單 set 貨物名稱='"+alltrim(thisform.text2.value)+"',進貨價格="+alltrim(thisform.text3.value)+",批發價="+alltrim(thisform.text4.value)+",零售價="+alltrim(thisform.text5.value)+" where 貨物名稱='"+alltrim(thisform.text1.value)+"'"

執行完這句代碼後,

假定
alltrim(thisform.text2.value)="11"
進貨價格=10
批發價=20,
零售價=30
alltrim(thisform.text1.value)="22"


sql="update 入貨單 set 貨物名稱='11',進貨價格=10,
批發價=20,
零售價=30
where 貨物名稱='22'"

你在代碼語句後輸出看是否是這樣的,如果是,在通過資料庫連接,執行sql即可。

2. SQL中怎樣用查詢命令,

在查詢分析器select * from 表名(table) where 姓名="(某人姓名)"

3. 用sql命令查詢數據

select * frm spec

4. sql有哪些基本命令

1、 查看資料庫中的表或查詢資料庫;

show tables/databases;

2、 查看資料庫中所有的表:

show tables;(前提是使用use database 資料庫;)

3、 查看數據表結構

describe 表名;

4、 創建資料庫

CARATE DATABASE 資料庫名;

create database studentoa;

5、 刪除資料庫

DROP DATABASE 資料庫名;

Drop database studentoa;

6、 使用資料庫

use 資料庫名;

use studentoa;

7、 創建數據表

CREATE TABLE 表名 ( 列名 數據類型, 列名 數據類型, 列名 數據類型 ); create table information ( id int primary key, name nvarchar(10) not null, age int, sex nvarchar(6) )

8、 刪除數據表中的列

ALTER TABLE 表名 DROP COLUMN 列名;

alter table information drop column sex;

9、 增加數據表中的列

ALTER TABLE 表名

ADD 列名 數據類型;

Alter table information add home varchar(20);

10、 數據表中添加數據

INSERT INTO 表名[(列名,列名,列名)] VALUES (值,值,值);

insert into information(id,name,age,home) values (001,』張三』,23,』黑龍江』);

insert into information values(002,』李四』,25,』沈陽』);

insert into information(id,name,home) values(003,』趙六』,』吉林』);

5. sql 插入命令

藉助EXCEL快速錄入數據的特性,來彌補SQL資料庫保存數據的優點:
將Excel的數據導入SQL server :
SELECT * into newtable FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0','Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')[Sheet1$]
實例:
SELECT * into newtable FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0','Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')sheet1$

6. SQL查詢語句命令

1.selectYGNAME員工名,YGBH編號,YGYX月薪fromEwhereYGBM='後勤部'

2.selectYGNAME員工名,YGBH編號,YGBM部門fromE
whereYGYXbetween10000and50000
andNIAN=2007

7. SQL查詢命令

1、select學號,姓名fromswhere班級='高會1'
2、select*fromswhere入學成績in(selecttop3入學成績from(selectdistinct入學成績froms)aorderby入學成績desc)
3、select*froms姓名like'%王%'

以上考慮成績並排情況


以下是不考慮成績並排的情況:

2、SELECTTOP3*FROMSORDERBY入學成績DESC

8. SQL查詢語句的命令

1.selectE.YGNAME員工名,E.YGBH編號,A.YGYX月薪fromE,AwhereE.YGBH=A.YGBH
andE.YGBM='後勤部'

2.selectE.*fromE,A
whereE.YGBH=A.YGBH
andA.YGYXbetween10000and50000
andA.NIAN=2007
andA.YUE=7

9. 請教sql命令代碼

哦,你是要刪除表1中符合的,還是刪除表2中的符合記錄的呢?還是都刪除?
1,如果是只要選擇的話
select a.a1,a.a2,a.a3,a.a4,b.b4
from 表1 a,表2 b
where a.a1=b.b1 and a.a2=b.b2 and a.a3=b.b3
2,如果你要刪除表1符合要求的記錄
delete from 表1 where (a1,a2,a3) in (select a.a1,a.a2,a.a3 from 表1 a,表2 b where a.a1 = b.b1 and a.a2 = b.b2 and a.a3 = b.b3) c
3,如果你要刪除表2符合要求的記錄
delete from 表2 where (b1,b2,b3) in (select b.b1,b.b2,b.b3 from 表1 a,表2 b where a.a1 = b.b1 and a.a2 = b.b2 and a.a3 = b.b3) c
4,如果你都要刪除,那麼不能簡單的將2,3句子連起來寫,那樣不會成功,你需要一個中間媒介表來存儲信息。需要四句sql文:(#為中間表)
1) select a1,a2,a3 into # from
(select a1,a2,a3,a4,b4
from 表1 a,表2 b
where a.a1=b.b1 and a.a2=b.b2 and a.a3=b.b3) c
2)delete from 表1 where (a1,a2,a3) in (select a1,a2,a3 from #) c
3)delete from 表2 where (b1,b2,b3) in (select a1,a2,a3 from #) c
4) drop table #
我手上沒有裝SQL,語法可能有些錯誤,麻煩自己試一下。

10. 怎麼執行sql命令

執行sql命令步驟如下:

1、點擊頁面中的【SQL】。

以上就是執行sql命令的步驟。

熱點內容
玩qq三國要什麼樣的電腦配置 發布:2024-09-20 00:50:57 瀏覽:445
樹莓派zero編譯驅動 發布:2024-09-20 00:50:56 瀏覽:483
上傳文件文件夾找不到 發布:2024-09-20 00:26:32 瀏覽:915
承台箍筋加密區 發布:2024-09-20 00:26:31 瀏覽:228
筆記本什麼配置能流暢運行cf 發布:2024-09-20 00:14:19 瀏覽:952
實測華為編譯器 發布:2024-09-19 23:50:52 瀏覽:822
linux匯總 發布:2024-09-19 23:46:39 瀏覽:453
阿里雲伺服器環境搭建教程 發布:2024-09-19 23:21:58 瀏覽:837
黃色文件夾圖標 發布:2024-09-19 23:19:22 瀏覽:684
mysql資料庫導出導入 發布:2024-09-19 23:00:47 瀏覽:183