Jump to content

SQL field like '%field2'


daiwa

Recommended Posts

I tried googling this but the search terms give off some very erratic results since it is very general.

What i am looking to do is something like this:

SELECT * FROM table WHERE `field1` LIKE %`field2`

this meaning that i want the rows where field 1 contains field2 at the end. (hence the %)
these being text fields.

Mysql 4.1
Link to comment
https://forums.phpfreaks.com/topic/4164-sql-field-like-field2/
Share on other sites

I don't think it can be done, although i may be wrong


SELECT * FROM table WHERE `field1` LIKE `field2`

works fine, but seeing as that is effectively the same as using = instead of like, it's pretty pointless.

I guess you will need to select the values prior to the LIKE query, and use values instead of field references.

Link to comment
https://forums.phpfreaks.com/topic/4164-sql-field-like-field2/#findComment-15801
Share on other sites

[!--quoteo(post=353276:date=Mar 9 2006, 10:35 AM:name=lessthanthree)--][div class=\'quotetop\']QUOTE(lessthanthree @ Mar 9 2006, 10:35 AM) [snapback]353276[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I guess you will need to select the values prior to the LIKE query, and use values instead of field references.
[/quote]

is this even possible in pure sql(or mysql sql)? to go around assigning pseudo variables and the like?
Link to comment
https://forums.phpfreaks.com/topic/4164-sql-field-like-field2/#findComment-15803
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.