You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

跨表填充目标表列值时遇SQL语法错误,求排查指导

Fixing Your SQL Syntax Error (Near '.')

Yep, your query has two clear issues that are triggering that syntax error — let’s break them down and get it working:

1. Invalid Column Alias Syntax

The line a.Store_Picked_Up AS b.Store is the direct cause of the "." error. When using AS to rename a column, you can’t prefix the alias with a table name (like b.).

  • If your goal is to pull the Store column from the Picked_Up table (b) into your results, you don’t need the alias here at all — just reference b.Store directly.
  • If you were trying to rename a.Store_Picked_Up to Store, you’d write a.Store_Picked_Up AS Store (no table prefix on the alias).

Given your mention of "pulling values from another table to populate a column", I assume you want the Store column from b.

2. Missing ON Clause for INNER JOIN

Standard SQL requires an ON clause to define the join condition for INNER JOIN. While some databases let you use WHERE as a workaround, this isn’t best practice and can lead to unexpected behavior. Your join condition a.EmailAddress = b.EmailAddress belongs right after the JOIN statement, not in the WHERE clause.

Corrected Query

Here’s the fixed version that addresses both issues:

SELECT a.*, b.Store
FROM [Master_List] a
INNER JOIN [Picked_Up] b
    ON a.EmailAddress = b.EmailAddress

If you actually intended to rename a.Store_Picked_Up instead (though that doesn’t require joining b), it would look like this:

SELECT a.*, a.Store_Picked_Up AS Store
FROM [Master_List] a
-- Only add the JOIN if you need data from b for other columns
INNER JOIN [Picked_Up] b
    ON a.EmailAddress = b.EmailAddress

内容的提问来源于stack exchange,提问作者JaylovesSQL

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 10:02:28