Merging two queries and I get syntax errors
Merging two queries and I get syntax errors
b.namba,
a.mlipaji,
a.kiasi,
a.imelipwaje,
to_char(a.kwa_mwezi_wa::timestamp with time zone, 'yyyy'::text) AS mwaka,
to_char(a.kwa_mwezi_wa::timestamp with time zone, 'mm'::text) AS mwezi
FROM michango2 a,
majina2 b
WHERE a.mlipaji = b.namba
ORDER BY ((((b.jina::text || ' '::text) || b.baba::text) || ' '::text) || b.babu::text), (to_char(a.kwa_mwezi_wa::timestamp with time zone, 'yyyy'::text)), (to_char(a.kwa_mwezi_wa::timestamp with time zone, 'mm'::text));
SELECT (((b.jina::text || ' '::text) || b.baba::text) || ' '::text) || b.babu::text AS jina_kamili, b.namba, a.mlipaji, a.kiasi, a.imelipwaje, to_char(a.kwa_mwezi_wa::timestamp with time zone, 'yyyy'::text) AS mwaka, to_char(a.kwa_mwezi_wa::timestamp with time zone, 'mm'::text) AS mwezi, (EXTRACT(YEAR FROM AGE(anza_mchango, CASE WHEN mwisho_mchango ISNULL THEN NOW() ELSE mwisho_mchango END))*12 + EXTRACT(MONTH FROM AGE(anza_mchango, CASE WHEN mwisho_mchango ISNULL THEN NOW() ELSE mwisho_mchango END)))*-1 AS miezi_deni
FROM michango2 a, majina2 b
WHERE a.mlipaji = b.namba
ORDER BY ((((b.jina::text || ' '::text) || b.baba::text) || ' '::text) || b.babu::text), (to_char(a.kwa_mwezi_wa::timestamp with time zone, 'yyyy'::text)), (to_char(a.kwa_mwezi_wa::timestamp with time zone, 'mm'::text));
Here it does not work and I get the message:
ERROR: syntax error at or near "a"
LINE 1: ...1 AS miezi_deni FROM michango2 a, majina2 b WHERE a.mlipaji
and it point at a.mlipaji
I would appreciate any hint.
Thanks in advance
Re: Merging two queries and I get syntax errors
FROM michango2 a, majina2 b
WHERE a.mlipaji = b.namba
Here it does not work and I get the message:
ERROR: syntax error at or near "a"
LINE 1: ...1 AS miezi_deni FROM michango2 a, majina2 b WHERE a.mlipajiand it point at a.mlipaji
Re: Merging two queries and I get syntax errors
On Saturday, March 21, 2026, Ibrahim Shaame <ishaame@gmail.com> wrote:FROM michango2 a, majina2 b
WHERE a.mlipaji = b.namba
Here it does not work and I get the message:
ERROR: syntax error at or near "a"
LINE 1: ...1 AS miezi_deni FROM michango2 a, majina2 b WHERE a.mlipajiand it point at a.mlipaji
Nothing seems obviously wrong which leads me to suspect some nonprinting character issues. Try writing/rebuilding the query in small increments until you get the error again then manually retype the last added chunk. Or just take the opportunity to use a more conventional explicit ANSI join syntax and move the join condition to the ON clause, getting rid of the where clause with the apparent issue.David J.