选择使用OR和NAND查询 [英] Select Query with OR and NAND
问题描述
我正在尝试使用OR和NAND操作设计查询,可以让我知道查询是否正确:
I am trying to design a query with OR and NAND operation, Can some one let me know Is the query is correct:
select * from country where country_code='AL' UNION (SELECT * from country
WHERE country_id NOT IN
(SELECT country_id from country
where country_name='Land islands'
UNION
SELECT country_id from country
where country_code='AX'
));
我在我的另一个问题的帮助下创建了查询;
I created the query with the help of my another question of mine;
我想使用5个查询,并且它们之间进行AND,NOT,NAND,OR操作. 我最多创建了3个(请问我的问题1),我需要创建5个选择查询的帮助.
I want to use 5 query with AND,NOT,NAND,OR operation in between them. I created up to 3 (Check my Question 1) I need help for creating 5 Select Queries.
我的应用程序"是搜索应用程序,用户可以在每个块之间使用i5查询块搜索数据库,我们进行了如下所述的操作.但是这些操作是在一个表中进行的.
My Application is search application where the user can search the database with i5 query block in between each block we have operations like below I mentioned. But the operations are carried out in one single table.
说明:
我想选择表中的记录,并且我将在表之间使用许多操作. MAX 5操作中的一个查询.
I want to select records inside a table and I will use many operations in between the table. MAX 5 operation in side a query.
查询1,查询2,查询3,查询4,查询5.
Query 1,Query 2, Query 3, Query 4, Query 5.
情况:
(Query 1 AND Query 2 OR Query 3 NAND Query 4 NOT Query 5)
(Query 1 OR Query 2 OR Query 3 OR Query 4 OR Query 5)
(Query 1 AND Query 2 AND Query 3 AND Query 4 AND Query 5)
(Query 1 NOT Query 2 NOT Query 3 NOT Query 4 NOT Query 5)
等.查询块之间的操作可能有所不同...我将据此编写PHP脚本,但我想以可以加入每个逻辑的方式执行逻辑.
etc.. The operation in between the query Block may vary... I will write my PHP script according to that but I want to perform the Logic in such a way that I can join each logic..
现在我需要帮助
推荐答案
为什么在同一Table
之间使用UNION
.您可以使用operators
like
Why you are using the UNION
in between same Table
. You may easily complete this query by using operators
like
Select * from country where country_code='AL' or (country_name <> 'Land islands' and country_code <> 'AX');
希望它对您有用.
这篇关于选择使用OR和NAND查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!