一个中有更多SQL查询[重复]

一个中有更多SQL查询[重复]

问题描述:

This question already has an answer here:

Is it possible to use this command in SQL?

$q1 =  $sql->query("
SELECT base_item 
  FROM items 
 WHERE id = **199415179;199444567;199459162;199397746;199397747;**
")->fetch_object()->base_item;

The IDS who are BOLD are diffrent id's, and my problem is, that this id's are pasted in one SQL table...

thanks a lot for your answers...

</div>

此问题已经存在 这里有一个答案: p>

  • 在数据库列中存储分隔列表真的那么糟糕吗? 10条答案 span> li> ul> div>

    是否有可能 在SQL中使用此命令? p>

      $ q1 = $ sql-&gt; query(“
    SELECT base_item 
     FROM items 
     WHERE id = ** 199415179; 199444567;  199459162; 199397746; 199397747; ** 
    “) - &gt; fetch_object() - &gt; base_item; 
      code>  pre> 
     
     

    BOLD的IDS是不同的ID,并且 我的问题是,这个id被粘贴在一个SQL表中...... p>

    p>

    非常感谢您的回答...... p> DIV>

You can use IN. Some example code:

$q1 =  $sql->query("SELECT base_item FROM items WHERE id IN (".str_replace(';',',', '199415179;199444567;199459162;199397746;199397747').") ")->fetch_object()->base_item;

You could use the IN function and comma seperate them:

SELECT base_item FROM items WHERE id IN(199415179,199444567,199459162,199397746,199397747)