简体   繁体   English

如何在sql查询中编写php代码?

[英]how to write php code inside sql query?

the code is like this 代码是这样的

$sql="SELECT tahun FROM tahunajar ";

i want the value of $sql can write in this query 我想要$ sql的值可以写在此查询中

$sql1= "SELECT * FROM soal where idSoal LIKE '-->HERE<--' "; 

can someone tell me how do it? 有人可以告诉我怎么做吗?

当然,你可以这样写

$sql1= "SELECT * FROM soal where idSoal IN (".$sql.") "; 

Simply use the variable in double quoted string. 只需在双引号字符串中使用变量。 It will work. 它会工作。 Following is the example: 以下是示例:

$sql1= "SELECT * FROM soal where idSoal LIKE $sql"; 

You can learn more from HERE . 您可以从此处了解更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM