Home > Backend Development > PHP Tutorial > 求 sql select怎么同时查询2个值

求 sql select怎么同时查询2个值

WBOY
Release: 2016-06-23 14:23:20
Original
1733 people have browsed it

比如 在数据库中 一个键hide=y和hide=n 要同时实现出等于y和n的数据要怎么写
sql的语句不是很懂 我是这么写的 虽然没报错
SELECT * FROM blog WHERE type='$type' $author and hide='y' and hide='n' $condition $limit
但是却都不显示
SELECT * FROM blog WHERE type='$type' $author and hide='y' $condition $limit
这样就可以 但是这能显示等于Y的 不能实现出等于n的


回复讨论(解决方案)

你的 $author $condition 分别是什么?

类似的,修改看看

SELECT * FROM `blog`  WHERE `type` = "$type"     AND `author` = "$author"     AND `hide` in ("y", "n")LIMIT
Copy after login

用or不就可以了嘛。干嘛要用and呀~怎么可能同时等于y又等于n

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template