开发者

SQL / SQLite, need query to check all of the strings in a column

开发者 https://www.devze.com 2023-03-18 07:50 出处:网络
I h开发者_运维百科ave a table with the following columns [itemdate][itemID][itemspecialid] itemID contains a string with multiple ideas, (ie. [54] [60] [96] [30]) as it is a set of IDs, only some en

I h开发者_运维百科ave a table with the following columns

[itemdate][itemID][itemspecialid]

itemID contains a string with multiple ideas, (ie. [54] [60] [96] [30]) as it is a set of IDs, only some entries have an itemspecialid which is actually only associated with one [itemID] of the set.

I am actually using java, so I will be parsing each [itemID] entry using myString.contains("[60]") which will have retrieved an itemID string set from the database, and then compared within myString looking for a particular value.

What would the SQL query be for selecting rows with [itemspecialid]'s populated? Once I get the basic query I can figure out how this is done within my language


Not sure I understood correctly, but if you want to get the rows where itemspecialid is not null, the query is

select itemdate, itemID, itemspecialid from mytable where itemspecialid is not null

It's a bad idea to store multiple information inside a single column. You should have a separate table to store the itemIDs of your items.

0

精彩评论

暂无评论...
验证码 换一张
取 消