select * from table t where t.a like '%'||t.b||'%';
select * from table t where t.a like '%'||var||'%'
(PL/SQL, fields a and b must be of string type, var is a string variable in the program, or more precise matching can use regular expressions, but the method is the same through string concatenation)
Use a concat function. You can turn the variable you want to match into something similar to a regular expression. For example: there are two fields in the user table, one is called username and the other is password. If you first want Find the line containing username in password, you can write it like this:
select username,password from user where password like concat('%',username,'%');
(PL/SQL, fields a and b must be of string type, var is a string variable in the program, or more precise matching can use regular expressions, but the method is the same through string concatenation)
sry The above is written backwards, it should be like this. If it is not mysql, the splicing method may be different.
SELECT *
FROM
aaa
where instr('$var',aaa.city)
I found this from the Internet and found it useful.
Use a concat function. You can turn the variable you want to match into something similar to a regular expression. For example: there are two fields in the user table, one is called username and the other is password. If you first want Find the line containing username in password, you can write it like this: