I'm trying to select from a table where a column which has a string in it matches some criteria.
the normal way without the string scenario is like this:
SELECT * FROM tablename HWERE columnName='something'
but lets say the columnName
contains a value like this:
1,2,3,4 | someemail@yahoo.com
and we want to select from the table where the columnName contains the someemail@yahoo.com
. So, how would i need to go about this?
I tried something like this but I'm 100% sure I'm doing it wrong:
SELECT SUBSTRING_INDEX(columnName,' | ',-1) from tableName
because I don't see how the WHERE
clause come in that statement!
Could someone please advise on this issue?
您需要使用LIKE
SELECT * FROM tablename WHERE columnName LIKE '%someemail@yahoo.com%'
使用LIKE
SELECT * FROM tablename WHERE columnName LIKE '%someemail@yahoo.com%';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.