MS Access sql错误查询
Posted
技术标签:
【中文标题】MS Access sql错误查询【英文标题】:MS Access sql error query 【发布时间】:2015-09-15 17:32:05 【问题描述】:我的代码
SELECT JuvCourt.ID,
JuvCourt.Category,
JuvCourt.Decision,
JuvCourt.intake_participant_role_code,
JuvCourt.[Screen In Date],JuvCourt.IDX,
JuvCourt.intake_type_code, JuvCourt.sex,
JuvCourt.RACE, JuvCourt.AGEFROM JuvCourt
Where JuvCourt.Category LIKE *" & searhtxt & "*"
给我语法错误(缺少运算符)...错误 3075
【问题讨论】:
【参考方案1】:你错过了 from 之前的一个空格
AGEFROM JuvCourt
【讨论】:
【参考方案2】:将where
条件更改为
Where JuvCourt.Category LIKE "*" & searhtxt & "*" --double-quote missing previously
double-quote
在*
周围丢失。
【讨论】:
没关系@JuanCarlosOropeza..但where
条件在like
之后缺少"
。【参考方案3】:
JuvCourt.AGEFROM JuvCourt
需要一个空间来成为
JuvCourt.AGE FROM JuvCourt
替换
*" & searhtxt & "*"
与
'%" & searhtxt & "%'"
【讨论】:
JuvCourt.Category LIKE ' "" & searhtxt & "" ' " Private Sub btnSearch_Click() Dim searchsql As String Dim searchtxt As String searchtxt = Me.txtSearch searchsql = "SELECT JuvCourt.ID, JuvCourt.Category, JuvCourt.Decision, JuvCourt.intake_participant_role_code, JuvCourt.[Screen In Date],JuvCourt.IDX, JuvCourt.intake_type_code, JuvCourt.sex, JuvCourt.RACE, JuvCourt.AGE FROM JuvCourt Where JuvCourt.Category LIKE "%" & 'searchtxt' & "%" " Me.SubJuvCourt.Form.RecordSource = searchsql Me.SubJuvCourt.Form.Requery End Sub 你知道单引号和双引号的区别吗? 我正在尝试各种组合......这是一个简单的代码相同的错误............ Private Sub cboGender_Change() Dim qGender As String qGender = "Select * from JuvCourt where ([sex] = '" & Me.cboGender & "')" Me.JuvCrt_Subfrm.Form.RecordSource = qGender Me.JuvCrt_Subfrm.Form.Requery End Sub以上是关于MS Access sql错误查询的主要内容,如果未能解决你的问题,请参考以下文章
库存 SQL 查询出现歧义错误,其中两个字段应相等以进行计算。 MS-ACCESS
带有子查询的 SQL 查询上的 MS Access VBA 运行时错误 3075