使用DataStudio时如何解决MariaDB中的Syntax Error
How can I solve the Syntax Error in MariaDB when I use DataStudio
我正在 Data Studio 中进行个性化查询,该查询最初是在 MySQL 中进行的,但是当我使用结果的一个字段时,我一直遇到下一个错误。
SQL 语句出错:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '>= '20200301' AND <= '20200331')' at line 34
这是查询,错误的文件是 pm.meta_value,它与 pm.meta_key:
有关
SELECT
p.ID as código,
p.post_title,
pm.meta_value,
entidad.name,
CASE WHEN tv.URL != ''
THEN 'SI'
ELSE 'NO'
END,
t.name,
tv.URL,
p.post_date
FROM wp_posts p
LEFT JOIN wp_postmeta pm on p.ID = pm.post_id
LEFT JOIN wp_term_relationships rs ON p.ID=rs.object_id
LEFT JOIN wp_term_taxonomy tt ON rs.term_taxonomy_id = tt.term_taxonomy_id
INNER JOIN wp_terms AS t ON tt.term_id = t.term_id
LEFT JOIN (select p.ID, pm.meta_value as URL FROM wp_posts p
LEFT JOIN wp_postmeta pm on p.ID = pm.post_id
where pm.meta_key in ('test')
and pm.meta_value != ''
) as tv on p.ID = tv.ID
INNER JOIN (select p.ID, t.name name, tt.taxonomy taxonomy FROM wp_posts p
LEFT JOIN wp_term_relationships rs ON p.ID=rs.object_id
LEFT JOIN wp_term_taxonomy tt ON rs.term_taxonomy_id = tt.term_taxonomy_id
INNER JOIN wp_terms AS t ON tt.term_id = t.term_id
) as entidad on p.ID = entidad.ID
WHERE p.post_type ='test1'
AND p.post_status = 'test2'
AND pm.meta_key = 'test3'
AND entidad.taxonomy = 'test4'
AND (tt.term_id = 15 OR
tt.term_id = 174 OR
tt.term_id = 1960);
错误是我将变量 p.ID 命名为 "código",因为 MariaDB 或 DataStudio 不接受字母 o 中的重音符号。
我正在 Data Studio 中进行个性化查询,该查询最初是在 MySQL 中进行的,但是当我使用结果的一个字段时,我一直遇到下一个错误。
SQL 语句出错:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '>= '20200301' AND <= '20200331')' at line 34
这是查询,错误的文件是 pm.meta_value,它与 pm.meta_key:
有关SELECT
p.ID as código,
p.post_title,
pm.meta_value,
entidad.name,
CASE WHEN tv.URL != ''
THEN 'SI'
ELSE 'NO'
END,
t.name,
tv.URL,
p.post_date
FROM wp_posts p
LEFT JOIN wp_postmeta pm on p.ID = pm.post_id
LEFT JOIN wp_term_relationships rs ON p.ID=rs.object_id
LEFT JOIN wp_term_taxonomy tt ON rs.term_taxonomy_id = tt.term_taxonomy_id
INNER JOIN wp_terms AS t ON tt.term_id = t.term_id
LEFT JOIN (select p.ID, pm.meta_value as URL FROM wp_posts p
LEFT JOIN wp_postmeta pm on p.ID = pm.post_id
where pm.meta_key in ('test')
and pm.meta_value != ''
) as tv on p.ID = tv.ID
INNER JOIN (select p.ID, t.name name, tt.taxonomy taxonomy FROM wp_posts p
LEFT JOIN wp_term_relationships rs ON p.ID=rs.object_id
LEFT JOIN wp_term_taxonomy tt ON rs.term_taxonomy_id = tt.term_taxonomy_id
INNER JOIN wp_terms AS t ON tt.term_id = t.term_id
) as entidad on p.ID = entidad.ID
WHERE p.post_type ='test1'
AND p.post_status = 'test2'
AND pm.meta_key = 'test3'
AND entidad.taxonomy = 'test4'
AND (tt.term_id = 15 OR
tt.term_id = 174 OR
tt.term_id = 1960);
错误是我将变量 p.ID 命名为 "código",因为 MariaDB 或 DataStudio 不接受字母 o 中的重音符号。