SQL查询不返回记录

时间:2018-09-18 04:30:41

标签: php

此查询未返回值,实际上在database中具有值。  红色标识查询问题。表是相关的其他外国表。  实际上,数据库where子句中的sylhet值不能正常工作。

select * from chamber where chamber_district = 'Sylhet'

enter image description here

enter image description here

2 个答案:

答案 0 :(得分:1)

在您的数据库中,chamer_district的值为“ sylhet sadar”,而您仅比较“ Sylhet”,这就是为什么它不返回数据的原因。如果您只想比较“ Sylhet”,则必须使用“ like”运算符,并且查询如下:

select * from chamber where chamber_district like 'Sylhet%'

答案 1 :(得分:0)

我可以解决这个问题。当我在查询 chamber_district 列下方输入内容时,通过'$ district'变量输入查询获取额外的空间。这个额外的空间无法在数据库中用肉眼显示。

正确的查询:

 $sql = "insert into chamber(doctor_id , chamber_district, area, consultation_center,additional_note, new_fee, returning_fee, report_fee ) values ( '$doctor_id' , '$district', '$area', '$consultation_center', '$additional_note', '$new_patient', '$return_patient' , '$report');"

先前的错误查询

$sql = "insert into chamber(doctor_id , chamber_district, area, consultation_center,additional_note, new_fee, returning_fee, report_fee ) values ( '$doctor_id' , '  $district  ', ' $area ', '$consultation_center', '$additional_note', '$new_patient', '$return_patient' , '$report');"
相关问题