Jump to content

[SOLVED] SQL Help on LIKE statement


SPraus

Recommended Posts

Hey everyone im trying to do a search through a HUGE database for a string but I dont wanna limit it to a single table.

This is what I have

SELECT DISTINCT * FROM aso WHERE * LIKE %'.$phpstring.'%

Can anyone give me help because the * dont work and without it dont work but I dont wanna search every table by sql lol.

Please lemme know.

SPraus

 

PS sorry if this sounds stupid (now that im thinking of it I think there is a rason but its late so ill still ask lol)

Link to comment
Share on other sites

Are all the fields from one table? If so you can do:

WHERE field1 LIKE "%'.$phpstring.'%" OR field2 LIKE "%'.$phpstring.'%" OR field3 LIKE "%'.$phpstring.'%" OR field4 LIKE "%'.$phpstring.'%"

 

If you need to search various tables you can accomplish this with a union statement or possibly a join depending on what data you want to retrieve.

 

 

Link to comment
Share on other sites

Thank you for the responce.

Lets see they are all in one table but anoter problem came up so I just changed the search type (just to one area) then being that most the tags were the same I created a dropdown box.

But thank you sou much for the help.

SPraus

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.