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
https://forums.phpfreaks.com/topic/154733-solved-sql-help-on-like-statement/
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.

 

 

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.