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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.