daiwa Posted March 5, 2006 Share Posted March 5, 2006 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 More sharing options...
daiwa Posted March 9, 2006 Author Share Posted March 9, 2006 anyone? Link to comment https://forums.phpfreaks.com/topic/4164-sql-field-like-field2/#findComment-15793 Share on other sites More sharing options...
lessthanthree Posted March 9, 2006 Share Posted March 9, 2006 I don't think it can be done, although i may be wrongSELECT * 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 More sharing options...
daiwa Posted March 9, 2006 Author Share Posted March 9, 2006 [!--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 More sharing options...
wickning1 Posted March 9, 2006 Share Posted March 9, 2006 It's possible, it's easy.SELECT * FROM table WHERE `field1` LIKE CONCAT('%', `field2`) Link to comment https://forums.phpfreaks.com/topic/4164-sql-field-like-field2/#findComment-15872 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.