select是SQL结构查询语言命令之一。
1)SQL 语句,定义结构查询语言 (SQL) 命令的表达式,例如 SELECT、UPDATE 或 DELETE,也可能包括像 WHERE 和 ORDER BY
这样的子句。SQL 字符串语句一般在查询和 rdoResultset
对象中使用,但也可以用来创建或修改数据库结构。
SQL 语句的语法与数据源有关。
2)SELECT - SQL命令
句法:
SELECT [ALL | DISTINCT] [TOP nExpr [PERCENT]]
[Alias] Select_Item [AS Column_Name]
[, [Alias] Select_Item [AS Column_Name] ]
FROM [FORCE]
[DatabaseName!]Table [[AS] Local_Alias]
[[INNER | LEFT [OUTER] | RIGHT [OUTER] | FULL [OUTER] JOIN
DatabaseName!]Table [[AS] Local_Alias]
[ON JoinCondition …]
[[INTO Destination]
| [TO FILE FileName [ADDITIVE] | TO PRINTER [PROMPT]
| TO SCREEN]]
[PREFERENCE PreferenceName]
[NOCONSOLE]
[PLAIN]
[NOWAIT]
[WHERE JoinCondition [AND JoinCondition ]
[AND | OR FilterCondition [AND | OR FilterCondition ]]]
[GROUP BY GroupColumn [, GroupColumn ]]
[HAVING FilterCondition]
[UNION [ALL] SELECTCommand]
[ORDER BY Order_Item [ASC | DESC] [, Order_Item [ASC | DESC] ]]
3)
SELECT - SQL命令例子:
下面的例子说明了如何使用SELECT的用户定义的函数用法。
例子1
例子1 显示所有企业在客户的名称(从一个表中的一个字段)。
SELECT customercompany FROM customer
例子2
例子2 显示两个表中三个字段的内容,并加入基于cust_id字段的两个表。它使用本地别名两个表。
SELECT acompany, border_date, bshipped_on FROM customer a, orders b WHERE acust_id = bcust_id
例子3
例子3 仅显示在指定领域唯一的数据记录。
SELECT DISTINCT acompany, border_date, bshipped_on FROM customer a, orders b WHERE acust_id = bcust_id
例子4
例子4 显示国家,邮编和公司按升序领域。
SELECT country, postalcode, company FROM customer ORDER BY country, postalcode, company
4)VB将上述例句作为字符串赋值给ADO数据对象,或者ADO数据访问控件属性,进而完成数据查询。
代码1:
Private Sub Command1_Click()Dim cnn As New Connection
Dim rs As New Recordset
Dim sql As String
Dim ARR
cnnOpen "Provider=MicrosoftJetOLEDB40;Data Source=C:\wdOldmdb;Persist Security Info=False"
sql = "select 故障名称 from guzhang_bm"
rsOpen sql, cnn
Combo1Text = "故障名称"
Do While Not rsEOF
Combo1AddItem rs("故障名称")
rsMoveNext '打开表
Loop
rsClose
cnnClose
End Sub
代码2:
Private Sub Form_Load()Adodc1ConnectionString = "Provider=MicrosoftJetOLEDB40;Data Source=D:\Program Files\Microsoft Visual Studio\VB98\BIBLIOMDB;Persist Security Info=False"
Adodc1RecordSource = "select from Authors"
Adodc1Refresh
DebugPrint Adodc1RecordsetFields(2)Name
Set DataGrid1DataSource = Adodc1
End Sub
select Bcid,s1serviceName,s2serviceName,s3serviceName
from service s1,service s2,service s3,
(select ccid, cserviceID1,cserviceID2,cserviceID3 from customer c,plan p where ccid=pcid and pcheckFlag=0)B
where s1serviceID=cserviceID1 and s2serviceID=cserviceID2 and s3serviceID=cserviceID3;
---
以上,希望对你有所帮助。
select
case
when userfen>400 then '金牌会员'
when userfen>300 and userfen <=400 then '银牌会员'
when userfen>200 and userfen <=300 then '铜牌会员'
else '注册会员'
end as '会员级别'
form tableName
以上就是关于VB中,怎样正确运用select语句全部的内容,包括:VB中,怎样正确运用select语句、数据库 select问题(难)、数据库中要用一段select case语句等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)