msql查詢中報錯 Unknown column '黃色水果' in 'where clause'
<?php
$positionarr = ['1'=>'綠色蔬菜','2'=>'紅色蔬菜','3'=>'黃色蔬菜', '4'=>'綠色水果', '5'=>'紅色水果', '6'=>'黃色水果'];
$position_id = 6; //水果型別
$position_name = $positionarr[$position_id];
$sql = "select a.type,a.url,a.name,a.businessid,a.tourl,a.startdate,a.enddate,b.id,b.name as bname from
".MFruitBaseinfo::tableName()." as a inner join ".MFruitPositioninfo::tableName()." as b on a.id=b.adid
where a.status=0 and b.status=0 and b.name=".$position_name."
order by b.displayorder desc,b.id desc";
$result = MFruitBaseinfo::getDb()->createCommand($sql)->query();
$rows = $result->readAll();
print_r($rows);
?>
執行上述程式碼報錯:[Err] 1054 - Unknown column '黃色水果' in 'where clause';
排錯:
表中明明有該欄位,,說明是sql語句有誤,,,後來將 b.name=".$position_name." 改為b.name='".$position_name."' 就可以了
相關文章
- Laravel 的 where or 查詢Laravel
- thinkphp6----where查詢PHP
- 在KYLIN中執行查詢報錯
- elasticSearch head 查詢報錯Elasticsearch
- navicat 新建查詢報錯
- 檢視查詢報錯
- Laravel 中 sql 查詢 使用 group by 報錯問題。LaravelSQL
- mysql Unknown column ‘‘ in ‘field list‘解決方案MySql
- 備忘:laravel 對查詢結果集可以迴圈where查詢Laravel
- MySQL查詢取別名報錯MySql
- PbootCMS 織夢提示Unknown column‘ad.clsid’in‘onboot
- webpack中css使用行內註釋報錯Unknown wordWebCSS
- Vuex中使用報錯unknown mutation typeVue
- FastCGI sent in stderr: "Primary script unknown" 報錯AST
- nginx 啟動報錯 unknown directive "server"NginxServer
- mysql報錯:Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggreMySqlExpressAI
- 記錄錯誤: *Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column ‘spec_templaMySqlJDBCExceptionError
- mysql,where條件查詢等學習筆記MySql筆記
- 去除idea中xml黃色背景IdeaXML
- ef8 Contains 查詢條件 報錯 $ 附近錯誤AI
- mysql主給備賦予許可權時報錯,MySQL [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clauseMySqlExpress
- MYSQL學習筆記6: DQL條件查詢(where)MySql筆記
- 如何在C#中除錯LINQ查詢C#除錯
- mysql 的delete from where 子查詢的一些限制MySqldelete
- windows 中nginx奇葩報錯 nginx: [emerg] unknown directive "#" in nginx/conf/nginx.conf:3WindowsNginx
- 使用linq查詢報錯English Message : Join a needs to be the same as OrderBy it
- 黃色氧化汞,黃色氧化汞價格,黃色氧化汞現貨供應
- 日誌查詢錯誤
- phpstrom用模型where查詢,欄位為什麼不會提示?PHP模型
- pbootcms模板報錯提示PHP Warning: Unknown: open_basedir restrictionbootPHPREST
- vscode中關於eslint的各種報黃線錯誤VSCodeEsLint
- 水果主題色創意logo效果Ps樣式Go
- 報錯:net::err_unknown_url_scheme的解決辦法Scheme
- react-native-vision-camera 掃二維碼報錯 [unknown/unknown] Waiting for the barcode module to be downloaded. Please wait.]ReactAI
- python實現查詢糾錯Python
- delphi 查詢av錯誤地址
- 錯誤:duplicate column name: picstitle
- Unknown column ‘name‘ in ‘field list‘ ; bad SQL grammar []; nested exception is com.mysql.jdbc.excepExceptionMySqlJDBC
- ORACLE 表char欄位混合儲存數字和字母類似資料時按數字的where條件查詢報錯ORA-01722Oracle