dss89001
2016-06-08 19:36
浏览 20
已采纳

如何在PHP MySQL中构建查询字符串

I'm building my php application that relates with a MySQL database. I have some problems doing specific queries since i'm not used doing complex ones. I want to find out how to build query string to do this: Based on "cad_proc" "sigla" i want to get "estado" from "juizo" to make sure that i'm looking for "cad_proc" that have "MG" on it.

Table1: cad_proc               
id - sigla  - ...             
01 - MG105  - ...                        
03 - M123   - ...            
Table2: juizo
sigla - estado -...
MG105 - MG
M123  - MG

My query so far is:

SELECT * FROM cad_processo WHERE sigla like '$UF';

Where $UF is an input from user.

图片转代码服务由CSDN问答提供 功能建议

我正在构建与MySQL数据库相关的php应用程序。 我在执行特定查询时遇到一些问题,因为我没有使用复杂的查询。 我想找出如何构建查询字符串来执行此操作: 基于“cad_proc”“sigla”我想从“juizo”获取“estado”以确保我正在寻找具有“MG”的“cad_proc” “在它上面。</ p>

 表1:cad_proc 
id  -  sigla  -  ... 
01  -  MG105  -  ... 
03  -  M123  -  ... 
Table2:juizo \  nsigla  -  estado -... 
MG105  -  MG 
M123  -  MG 
 </ code> </ pre> 
 
 

到目前为止,我的查询是:</ p>

 <  code> SELECT * FROM cad_processo WHERE sigla like'$ UF'; 
 </ code> </ pre> 
 
 

其中 $ UF </ code>是来自用户的输入。</ p > </ div>

4条回答 默认 最新

相关推荐 更多相似问题