![]() Note that although MySQL crashes, chaining unions in SQLite or Postgres works as expected. (See DISTINCT Clause below.) Using the operators UNION, INTERSECT, and EXCEPT. (SELECT `listing`.`id`, `listing`.`foo` FROM `listing`) UNION ((SELECT `listing`.`id`, `listing`.`foo` FROM `listing`) UNION (SELECT `listing`.`id`, `listing`.`foo` FROM `listing`)) SELECT ALL (the default) will return all candidate rows, including duplicates. Raise dj_exc_value.with_traceback(traceback) from exc_valueĭjango.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION (SELECT `listing`.`id`, `listing`.`foo` FROM `listing`))) subquery' at line 1") Return executor(sql, params, many, context)įile "/dir/.env/lib/python3.6/site-packages/django/db/utils.py", line 90, in _exit_ Return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)įile "/dir/.env/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers Share Improve this answer answered at 12:48 JNK 17. Number = obj.get_aggregation(using, )įile "/dir/.env/lib/python3.6/site-packages/django/db/models/sql/query.py", line 502, in get_aggregationįile "/dir/.env/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1151, in execute_sqlįile "/dir/.env/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in executeįile "/dir/.env/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute 4 Answers Sorted by: 8 Just do a LEFT JOIN instead: SELECT P.id, P.parent, GP.parent gpid FROM productgroups P LEFT JOIN productgroups GP ON P.parent GP.id That will return all rows from P and any non-matching rows in GP will have NULL values. ![]() Return _count(using=self.db)įile "/dir/.env/lib/python3.6/site-packages/django/db/models/sql/query.py", line 517, in get_count The above exception was the direct cause of the following exception:įile "/dir/.env/lib/python3.6/site-packages/django/db/models/query.py", line 397, in count expressionn FROM tables WHERE conditions expression1, expression2. expressionn FROM tables WHERE conditions UNION ALL DISTINCT SELECT expression1, expression2. MySQLdb._exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION (SELECT `listing`.`id`, `listing`.`foo` FROM `listing`))) subquery' at line 1") MySQL UNION SELECT SELECT MySQL UNION SELECT expression1, expression2. ![]() ![]() The track trace isįile "/dir/.env/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _executeįile "/dir/.env/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 74, in executeįile "/dir/.env/lib/python3.6/site-packages/MySQLdb/cursors.py", line 209, in executeįile "/dir/.env/lib/python3.6/site-packages/MySQLdb/cursors.py", line 315, in _queryįile "/dir/.env/lib/python3.6/site-packages/MySQLdb/connections.py", line 239, in query Unfortunately, this query crashes with a ProgrammingError exception. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |