我需要在字段" beruf_1 "时选择行不是零。
beruf_1是类型VARCHAR
这四个条目给我写错误。
$sql = "SELECT * from members WHERE beruf_1 LIKE != '0' ";
$sql = "SELECT * from members WHERE beruf_1 LIKE != 0 ";
$sql = "SELECT * from members WHERE beruf_1 LIKE > 0 ";
$sql = "SELECT * from members WHERE beruf_1 LIKE > 'a' ";
注意:尝试在第141行的xxxxxxx.php中获取非对象的属性
另:
$sql = "SELECT * from members WHERE beruf_1 LIKE '!= 0' ";
结果= 0
这样:
$sql = "SELECT * from members WHERE beruf_1 LIKE '%a%' ";
结果所有行,当字段 beruf_1 包含" a "
和此:
$sql = "SELECT * from members WHERE beruf_1 LIKE '%' ";
结果所有列表 - 无论是空的还是带有条目
你能帮助我吗?
答案 0 :(得分:0)
只需简单检查条件对您有用。
SELECT * from members WHERE beruf_1 != 0
就错误Notice: Trying to get property of non-object in xxxxxxx.php on line 141
而言,由于sql
错误导致此错误。
答案 1 :(得分:0)
检查不平等,因此您不需要LIKE功能。由于它是VarChar类型,你可能希望在它周围加上引号。
$sql = "SELECT * from members WHERE beruf_1 != '0' ";
实施例
members [table]
| ID | beruf_1 |
| 1 | 0 |
| 2 | 12 |
| 3 | 10 |
| 4 | 0 |
| 5 | 01 |
这应该返回
| ID | beruf_1 |
| 2 | 12 |
| 3 | 10 |
| 5 | 01 |
答案 2 :(得分:0)