Home > Backend Development > PHP Tutorial > SELECT时候,如何跳过带有空值字段的数据项?

SELECT时候,如何跳过带有空值字段的数据项?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:51:18
Original
1670 people have browsed it

以下是我的php代码:,

$sql = "SELECT author,tags,subject,tid,authorid,dateline,fid FROM threads ORDER BY dateline DESC LIMIT 10"
Copy after login
Copy after login

如果tags是空值,则跳过,该怎么改呢?

回复内容:

以下是我的php代码:,

$sql = "SELECT author,tags,subject,tid,authorid,dateline,fid FROM threads ORDER BY dateline DESC LIMIT 10"
Copy after login
Copy after login

如果tags是空值,则跳过,该怎么改呢?

如果空值是:NULL
则:

$sql = "SELECT author,tags,subject,tid,authorid,dateline,fid FROM threads WHERE tags IS NOT NULL ORDER BY dateline DESC LIMIT 10"
Copy after login

如果空值是:''

$sql = "SELECT author,tags,subject,tid,authorid,dateline,fid FROM threads WHERE tags !='' ORDER BY dateline DESC LIMIT 10"
Copy after login
Related labels:
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