我写了一个查询,我使用SPLIT_STR作为我的一个字段
SELECT id, approved_studied,
SPLIT_STR(approved_studied, '||', 8) as dissertation
SPLIT_STR(approved_studied, '||', 7) as university
FROM temp_users
现在我想过滤
在哪里论文喜欢'%种植%'或大学喜欢'%牛津%'
如何编写此子查询?这是我到目前为止所提出的:
SELECT P1.approved_studied, P1.dissertation
FROM P1
WHERE P1.dissertation LIKE '%Planting%' OR university LIKE '%Oxford%' (
SELECT id, approved_studied,
SPLIT_STR(approved_studied, '||', 8) as dissertation
SPLIT_STR(approved_studied, '||', 7) as university
FROM temp_users AS P1
)
这是非常古老的数据和编码:(我试图创建sql小提琴,但它没有让我继续。http://sqlfiddle.com/#!2/3bca40/7
答案 0 :(得分:2)
这里不需要子查询,只需添加where条件:
SELECT id, approved_studied,
SPLIT_STR(approved_studied, '||', 8) as dissertation,
SPLIT_STR(approved_studied, '||', 7) as university
FROM temp_users
WHERE SPLIT_STR(approved_studied, '||', 8) LIKE '%Planting%' AND
SPLIT_STR(approved_studied, '||', 7) LIKE '%oxford%'
请注意,您不能在where条件中使用别名。
字符串操作不会运行两次。