多表查询中sql类型不匹配错误

发布于 2024-12-09 07:45:25 字数 412 浏览 0 评论 0原文

AM 查询 Access 数据库,从两个表中选择记录,在 vb6 中使用以下查询,

SELECT stock.*,suppliers.id, suppliers.s_name as supplier FROM stock,suppliers 
WHERE stock.supplier_id=suppliers.id

但当我运行查询时出现以下错误,

-2147467259   Type mismatch in expression.   Microsoft JET Database Engine

任何人都可以告诉我出了什么问题,

谢谢

编辑

stock.supplier_id、suppliers.id 都是长整型数据类型

AM querying an access database, selecting records from two tables, in vb6 using the following query

SELECT stock.*,suppliers.id, suppliers.s_name as supplier FROM stock,suppliers 
WHERE stock.supplier_id=suppliers.id

but i get the following error when i run the query

-2147467259   Type mismatch in expression.   Microsoft JET Database Engine

can anyone tell me what is wrong

thanks

EDIT

Both stock.supplier_id, suppliers.id are long integer data type

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧伤还要旧人安 2024-12-16 07:45:25

stock.supplier_idsuppliers.id 必须具有兼容的类型才能使此等式发挥作用。

有一些可用的转换函数,因为您没有提供类型,所以 CStr 应该这样做。

此外,我建议您避免隐式连接:

SELECT stock.*,suppliers.id, suppliers.s_name as supplier 
FROM stock 
inner join suppliers 
on CStr(stock.supplier_id) = CStr(suppliers.id)

stock.supplier_id and suppliers.id must have compatible types for this equality to work.

There a a few converting functions available, since you have not provided the types, CStr should do it.

Additionally, I would advise you to avoid implicit joins:

SELECT stock.*,suppliers.id, suppliers.s_name as supplier 
FROM stock 
inner join suppliers 
on CStr(stock.supplier_id) = CStr(suppliers.id)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文