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 Quote Link to comment Share on other sites More sharing options...
daiwa Posted March 9, 2006 Author Share Posted March 9, 2006 anyone? Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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`) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.