MS Access 查询问题

发布于 2024-11-03 06:17:07 字数 1800 浏览 0 评论 0原文

SELECT 
     tbl_vehicle_models.model_name AS Vehicle_Model,
     tbl_vehicle_models.manufacturer AS Manufacturer,
     tbl_jobs.vehicle_registration_number AS Registration_Number,
     tbl_customers.first_name + " " + tbl_customers.last_name AS Customer_Name,
     tbl_customers.address AS Address,
     tbl_customers.contact_no AS Contact_Number,
     tbl_jobs.cost_charged AS Cost,
     tbl_jobs.was_accident AS Was_Accident,
     tbl_jobs.was_towed AS Was_Towed,
     tbl_jobs.job_call_time AS Call_Time,
     tbl_jobs.job_arrival_time AS Arrival_Time,
     tbl_jobs.job_leaving_scene_time AS Leaving_Time,
     tbl_places.place_name AS Place
FROM 
    tbl_jobs
    INNER JOIN  tbl_vehicle_models
       ON  ( tbl_vehicle_models.ID = tbl_jobs.vehicle_model ) 
    INNER JOIN tbl_customers
       ON ( tbl_customers.ID =  tbl_jobs.customer_id )
    INNER JOIN tbl_places
       ON ( tbl_places.ID = tbl_jobs.job_place ) 

这个查询有什么问题?我收到错误消息,指出查询表达式中缺少运算符 '( v.ID = j.vehicle_model ) 内连接 tbl_customers c ON ( c.id = j.customer_id ) INNER JOIN tbl_places p ON ( p.ID = j.job_place'

编辑:这解决了我的问题:

SELECT tbl_vehicle_models.model_name, tbl_vehicle_models.manufacturer, tbl_jobs.vehicle_registration_number, tbl_customers.first_name & " " & tbl_customers.last_name AS Expr1, tbl_customers.address, tbl_customers.contact_no, tbl_jobs.cost_charged, tbl_jobs.was_accident, tbl_jobs.was_towed, tbl_jobs.job_call_time, tbl_jobs.job_arrival_time, tbl_jobs.job_leaving_scene_time, tbl_places.place_name
FROM ((tbl_jobs INNER JOIN tbl_vehicle_models ON tbl_jobs.vehicle_model = tbl_vehicle_models.ID) INNER JOIN tbl_customers ON tbl_jobs.customer_id = tbl_customers.ID) INNER JOIN tbl_places ON tbl_jobs.job_place = tbl_places.ID;
SELECT 
     tbl_vehicle_models.model_name AS Vehicle_Model,
     tbl_vehicle_models.manufacturer AS Manufacturer,
     tbl_jobs.vehicle_registration_number AS Registration_Number,
     tbl_customers.first_name + " " + tbl_customers.last_name AS Customer_Name,
     tbl_customers.address AS Address,
     tbl_customers.contact_no AS Contact_Number,
     tbl_jobs.cost_charged AS Cost,
     tbl_jobs.was_accident AS Was_Accident,
     tbl_jobs.was_towed AS Was_Towed,
     tbl_jobs.job_call_time AS Call_Time,
     tbl_jobs.job_arrival_time AS Arrival_Time,
     tbl_jobs.job_leaving_scene_time AS Leaving_Time,
     tbl_places.place_name AS Place
FROM 
    tbl_jobs
    INNER JOIN  tbl_vehicle_models
       ON  ( tbl_vehicle_models.ID = tbl_jobs.vehicle_model ) 
    INNER JOIN tbl_customers
       ON ( tbl_customers.ID =  tbl_jobs.customer_id )
    INNER JOIN tbl_places
       ON ( tbl_places.ID = tbl_jobs.job_place ) 

What's wrong with this query? I am getting error saying missing operator in query expression '( v.ID = j.vehicle_model )
INNER JOIN tbl_customers c ON ( c.id = j.customer_id )
INNER JOIN tbl_places p ON ( p.ID = j.job_place'

Edit: This solved my problem:

SELECT tbl_vehicle_models.model_name, tbl_vehicle_models.manufacturer, tbl_jobs.vehicle_registration_number, tbl_customers.first_name & " " & tbl_customers.last_name AS Expr1, tbl_customers.address, tbl_customers.contact_no, tbl_jobs.cost_charged, tbl_jobs.was_accident, tbl_jobs.was_towed, tbl_jobs.job_call_time, tbl_jobs.job_arrival_time, tbl_jobs.job_leaving_scene_time, tbl_places.place_name
FROM ((tbl_jobs INNER JOIN tbl_vehicle_models ON tbl_jobs.vehicle_model = tbl_vehicle_models.ID) INNER JOIN tbl_customers ON tbl_jobs.customer_id = tbl_customers.ID) INNER JOIN tbl_places ON tbl_jobs.job_place = tbl_places.ID;

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

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

发布评论

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

评论(2

原野 2024-11-10 06:17:07

您确定 v.IDj.vehicle_model 具有相同的数据类型吗?

看起来 v.ID 是一个整数,而 j.vehicle_model 是一个字符串,

我认为当您尝试使用具有不兼容操作数数据类型的运算符时会发生此问题。

编辑:
然后,尝试更改

c.first_name + " " + c.last_name

c.first_name & " " & c.last_name

I think that's a Problem with this concatenation

Are you sure that v.ID and j.vehicle_model have the same data type?

Looks like v.ID is an integer and j.vehicle_model a string

I think this problem happens when you try to use operators with incompatible operand data types.

EDIT:
Then, try changing

c.first_name + " " + c.last_name

to

c.first_name & " " & c.last_name

I think that's a problem with this concatenation

慵挽 2024-11-10 06:17:07

这解决了我的问题:

 SELECT tbl_vehicle_models.model_name, tbl_vehicle_models.manufacturer,
    tbl_jobs.vehicle_registration_number, tbl_customers.first_name & " " &
    tbl_customers.last_name AS Expr1, tbl_customers.address, tbl_customers.contact_no, 
    tbl_jobs.cost_charged, tbl_jobs.was_accident, tbl_jobs.was_towed, tbl_jobs.job_call_time,
    tbl_jobs.job_arrival_time, tbl_jobs.job_leaving_scene_time, tbl_places.place_name

    FROM ((tbl_jobs 
     INNER JOIN tbl_vehicle_models ON tbl_jobs.vehicle_model = tbl_vehicle_models.ID)
     INNER JOIN tbl_customers ON tbl_jobs.customer_id = tbl_customers.ID) 
     INNER JOIN tbl_places ON tbl_jobs.job_place = tbl_places.ID;

This solved my problem:

 SELECT tbl_vehicle_models.model_name, tbl_vehicle_models.manufacturer,
    tbl_jobs.vehicle_registration_number, tbl_customers.first_name & " " &
    tbl_customers.last_name AS Expr1, tbl_customers.address, tbl_customers.contact_no, 
    tbl_jobs.cost_charged, tbl_jobs.was_accident, tbl_jobs.was_towed, tbl_jobs.job_call_time,
    tbl_jobs.job_arrival_time, tbl_jobs.job_leaving_scene_time, tbl_places.place_name

    FROM ((tbl_jobs 
     INNER JOIN tbl_vehicle_models ON tbl_jobs.vehicle_model = tbl_vehicle_models.ID)
     INNER JOIN tbl_customers ON tbl_jobs.customer_id = tbl_customers.ID) 
     INNER JOIN tbl_places ON tbl_jobs.job_place = tbl_places.ID;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文