I’m having trouble with a stubborn MySQL query. It’s a quite long and complex query, sorry about that. I really did my best to find it myself but I could use a hand here.
The following query is used to emulate a full outer join of column information in the information_schema, and column information in a table called nexedit_schema. The PHP variable $db contains the target database that contains the latter table.
The query actually successfully runs on my own server (MySQL version 5.1), but fails to run on a friend’s server (MySQL version 5.5). It claims that I have a syntax error near “ON (schema_tables.db_table…”
I’m probably overlooking something really stupid. Anyone kind enough to help me out?
SELECT information_schema.tables.table_name, schema_tables.db_table, schema_tables.ne_page
FROM information_schema.tables
LEFT JOIN (
(SELECT DISTINCT db_table, ne_page FROM {$db}.nexedit_schema)
AS schema_tables)
ON (schema_tables.db_table = information_schema.tables.table_name
COLLATE utf8_unicode_ci)
WHERE information_schema.tables.table_schema = '{$db}'
AND information_schema.tables.table_name NOT LIKE 'nexedit_%'
UNION
SELECT information_schema.tables.table_name, schema_tables.db_table, schema_tables.ne_page
FROM information_schema.tables
RIGHT JOIN (
(SELECT DISTINCT db_table, ne_page FROM {$db}.nexedit_schema)
AS schema_tables)
ON (schema_tables.db_table = information_schema.tables.table_name
COLLATE utf8_unicode_ci)
WHERE information_schema.tables.table_schema IS NULL
AND schema_tables.db_table NOT LIKE 'nexedit_%'
GROUP BY information_schema.tables.table_name,schema_tables.db_table;
There’s unnecessary
)here:AS schema_tables)Should be beforeAS