Tha*_*ran -2 mysql database ios
在我的数据库中,我有date_ID一个字符串字段如下:
----------------------------------
+ date_ID +
----------------------------------
111-11-333 555+33+22 -00000
111-22-333 555+33+22 -00569 -- > element 1
111-05-333 555+33+22 -00789
111-22-333 555+33+22 -00008 -- > element 2
111-22-333 555+33+22 -00001 -- > element 3
111-22-111 555+33+22 -00001 -- > element 4
----------------------------------
Run Code Online (Sandbox Code Playgroud)
如何选择date_ID包含111-22前缀的所有字符串?
表是动态的.我是mySql的新手,所以请帮忙.
更新的问题
我在iOS中这样做,所以我也对语法感到困惑.所以,请帮我把字符串作为下面的表格.
NSString *passedPrefix = @"111-22";
[NSString stringWithFormat:@"select * from my_table WHERE date_ID LIKE \"%@\"",passedPrefix]
// How to add that last '%' here?
Run Code Online (Sandbox Code Playgroud)
只需使用LIKE运营商:
SELECT * FROM mytable WHERE date_id LIKE '111-22%'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
186 次 |
| 最近记录: |