0

There is a column in my DB where data is stored like:

/accounts/2/xyz/a
/accounts/2/xyz/b
/accounts/3/xyz/a
/accounts/3/xyz/b
/accounts/5/xyz/a
/accounts/5/xyz/b

Now, I have list of selected accounts let's say account_id=[2,5]. I want to fetch data for the following keys /accounts/<acount_id>/xyz/a So, what will be the optimal query for fetching such data? For now, I am generating keys for the selected account_id list and firing query over that but I don't want to do that.

4

1 回答 1

1
select * FROM  tbl where accountNumber like '/accounts/%/xyz/a'

参考http://dev.mysql.com/doc/refman/5.1/en/regexp.html

于 2013-02-10T12:42:36.190 回答