mysql - 在 WHERE 中添加 OR
问题描述
我有 SQL 查询:
SELECT
p.ID,
p.post_author,
p.post_status,
p.post_name,
p.post_parent,
p.post_type,
p.post_date,
p.post_date_gmt,
p.post_modified,
p.post_modified_gmt,
p.comment_count
FROM
{$wpdb->posts} p
WHERE
p.post_password = ''
AND p.post_type = '%s'
AND p.post_status = 'publish'
AND YEAR(p.post_date_gmt) = %d
AND MONTH(p.post_date_gmt) = %d
{$exPostSQL}
{$exCatSQL}
ORDER BY
p.post_date_gmt DESC
我想调整它,让它寻找p.post_status = 'publish'
OR p.post_status = 't_active'
。
我试过了:
AND p.post_status = 'publish' OR p.post_status = 't_active'
但它没有用。你如何做到这一点?
这是一个入门级问题 - SQL 不是我的爵士乐。
解决方案
尝试使用AND (p.post_status = 'publish' OR p.post_status = 't_active')
推荐阅读
- snakemake - 集群执行失败后保留 Snakemake 作业脚本?
- apache-kafka-connect - Apache Kafka Connect 与 OracleApps
- mysql - 从 mysql 迁移到 oracle 命中 ora-01400
- mysql - 如何在mysql对象中写入where条件
- c# - C# - 包含字母条目和字母数字条目的排序列表
- c# - 如何减少洋葱架构中的注入服务?
- c++ - 使用向量在 C++ 中通过 d 个元素向左旋转数组
- javascript - 集群响应多次的 Discord.js 机器人
- excel - 从数据中提取所需的字符串
- excel - Excel 公式 - 计算总百分比