Welcome to WebmasterWorld Guest from 54.147.134.218

Forum Moderators: open

Message Too Old, No Replies

newbie query

OR statement?

     
8:47 pm on Jun 25, 2010 (gmt 0)

New User

5+ Year Member

joined:June 25, 2010
posts: 5
votes: 0


I can't seem to work this out. Spent about 30 minutes digging through the net.

Why doesn't this work:

"SELECT client_id,fname,lname FROM clients WHERE fname OR lname = '$search_val'";

Thanks!
8:53 pm on June 25, 2010 (gmt 0)

Moderator from US 

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 10, 2005
posts:5551
votes: 24


Welcome [webmasterworld.com] to WebmasterWorld!

Why doesn't this work

Because there is no conditional on fname.

I believe this is what you mean:
SELECT client_id,fname,lname
FROM clients
WHERE fname = '$search_val' OR lname = '$search_val'
8:54 pm on June 25, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Feb 22, 2009
posts:1396
votes: 0


Hi there Discord,

Welcome to the forum :)

Good news is you are almost there, try this:-

"SELECT `client_id`, `fname`, `lname` FROM `clients` WHERE `fname` = '".$search_val."' OR `lname` = '".$search_val."' ";

That should be ok, you see the logic there hopefully,

[EDIT:] Great minds think alike ;)

Cheers,
MRb

[edited by: Matthew1980 at 8:55 pm (utc) on Jun 25, 2010]

8:55 pm on June 25, 2010 (gmt 0)

New User

5+ Year Member

joined:June 25, 2010
posts:5
votes: 0


a-ha! so simple.

Thank you!