Log in

View Full Version : Resolved search in all tables



TwitterRooms
01-27-2012, 05:58 PM
hi guys me again this is what i have


$result = mysql_query("SELECT * FROM table WHERE firstname LIKE '%".$searchterm."%'");

which works just great BUT if i want to seach

$result = mysql_query("SELECT * FROM table WHERE lastname LIKE '%".$searchterm."%'");

how so search ALL rows/columns firstname,lastname,username ect

P.S i'm getting it slowly lol

james438
01-27-2012, 08:53 PM
It looks like you want to search through multiple columns in one table as opposed to searching through multiple tables, but let me know if I am wrong.

Try this


SELECT * FROM table WHERE (lcase(concat(firstname, lastname, username)) LIKE '%$searchterm%')

TwitterRooms
01-27-2012, 09:37 PM
you are correct THANK YOU

james438
01-28-2012, 08:07 AM
Glad I could help :)