如何在SQL查询中使用两个where子句 [英] How can I use two where clauses in a SQL query
本文介绍了如何在SQL查询中使用两个where子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我正在学习SQL并尝试使用两个'where'子句进行查询,其中一个只是一个简单的WHERE status ='error',此外,我还需要添加第二个'WHERE',但是也使用'LIKE',我的查询看起来像这样:
So I'm learning SQL and trying to make a query with two 'where' clauses, one of them is just a simple WHERE status='error', and in addition I need to a add a second 'WHERE' but using also 'LIKE', my Query looks something like this:
SELECT sync.id
WHERE status='ERROR'
WHERE search LIKE '%sometext%'
但是我一直在读的是不可能做到这一点,既然这两个语句都是必需的,那么我该如何使用这两个语句呢?
But what I've been reading is that is not possible to do that, how can I use the two statements since both are required?
推荐答案
使用AND进行这种尝试,以使SELECT上同时需要两个条件.
Try like this way by using AND to make both conditions are required on the SELECT.
N.B:您错过了FROM子句
N.B: You missed the FROM clause
SELECT sync.id FROM table_name_goes_here
WHERE status='ERROR' AND
search LIKE '%sometext%'
这篇关于如何在SQL查询中使用两个where子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文