需要为数组中的每个值执行数据库选择功能

我需要为数组中的每个值执行数据库选择功能。参数theRequestApplicationName包含一个数组,如


["fb","dropbox","twitter"]


我需要选择功能,在下面提到的查询中,它应该类似于 application.name = 数组的每个值。请帮我解决这个问题


ApplicationLogoutUrl = function (theRequestId, theRequestApplicationName, theRequestOrg, connection, res)

{

   theQuery = "select org_uses_app.app_logout_url 

                from  application, org_uses_app 

                where application.id=org_uses_app.application 

                and application.name = --";

}


江户川乱折腾
浏览 177回答 3
3回答

UYOU

你的 sql 查询应该是这样的 -//$array variable is your array name like below// $array = ["fb","dropbox","twitter"]; theQuery = "select org_uses_app.app_logout_url from  application, org_uses_app              where application.id=org_uses_app.application and application.name IN              ('$array[0]','$array[1]','$array[2]')";

呼啦一阵风

对于多个搜索值,您可以使用IN这里的答案中的 sql 查询SQL 在同一字段中搜索多个值

繁星淼淼

查询的基本结构可以是    SELECT item FROM database.table WHERE firstCondition OR secondCondition假设数据库被命名applications,具有apps以下属性的表id和name一条记录{id: 'fb', name: 'facebook'},php中的查询将是    SELECT app_logout_url     FROM applications.apps     WHERE id = fb  OR name = facebook;
打开App,查看更多内容
随时随地看视频慕课网APP