我的桌子如下:
+----------+----------+
|stud_id |stud_name |
+----------+----------+
|101 |A |
|102 |B |
|103 |C |
|104 |D |
|105 |E |
+----------+----------+
我的查询
SELECT * FROM students_tbl stud WHERE stud.stud_id IN (:s_id);
当我输入102时,它返回:
+----------+----------+
|stud_id |stud_name |
+----------+----------+
|102 |B |
+----------+----------+
与预期的一样。
有没有一种方法可以输入多个值,例如102,103,104,并得到这样的结果?:
+----------+----------+
|stud_id |stud_name |
+----------+----------+
|102 |B |
|103 |C |
|104 |D |
+----------+----------+
答案 0 :(得分:1)
您可以将context.insert(newSettings)
与 @IBAction func saveTapped(_ sender: UIBarButtonItem) {
guard let context = persistentContainer?.viewContext else { return }
let newSettings = Settings(context: context)
newSettings.ingredients = self.ingredients.rawValue
self.saveData()
}
一起使用。
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ExecuteQuickSearchWithModuleIds xmlns="http://archer-tech.com/webservices/">
<sessionToken>ABC123ABC123ABC123ABC123ABC1</sessionToken>
<moduleIds>123</moduleIds>
<keywords>INC-1234</keywords>
<pageNumber>9999999</pageNumber>
<pageSize>9999999</pageSize>
</ExecuteQuickSearchWithModuleIds>
</soap:Body>
</soap:Envelope>
干杯!
答案 1 :(得分:1)
您不需要拆分绑定变量的值;更快的解决方案是查看id(加上周围的定界符)是否是bind变量(带有前导和尾随定界符)的子字符串:
select *
from students_tbl
where ','||:s_id||',' LIKE ','||stud_id||','
答案 2 :(得分:0)
下面的查询将要求您输入3个输入值,您将获得所需的结果
SELECT * FROM students_tbl stud WHERE stud.stud_id IN (:s_id,:s_id1,:s_id2);