如何根据两个查询中的哪一个来对联合查询的结果进行排序?

时间:2019-01-14 19:05:34

标签: sql

基本上我想要这个:

  File "/anaconda3/lib/python3.6/site-packages/sqlalchemy/engine/__init__.py", line 419, in create_engine
    return strategy.create(*args, **kwargs)
  File "/anaconda3/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 80, in create
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 102, in dbapi
    return __import__('MySQLdb')
ModuleNotFoundError: No module named 'MySQLdb'

如果有趣的结果很少,我会这样做,以便用随机的结果填充它们。

1 个答案:

答案 0 :(得分:3)

您只需要一个ORDER BY

SELECT column
FROM Table 
ORDER BY (CASE WHEN column LIKE '%interesting%' THEN 1 ELSE 2 END);