Welcome to WebmasterWorld Guest from 54.167.0.111

Forum Moderators: open

Message Too Old, No Replies

newbie query

OR statement?

     

discord

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

5+ Year Member



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!

LifeinAsia

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

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



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'

Matthew1980

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

WebmasterWorld Senior Member 5+ Year Member



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]

discord

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

5+ Year Member



a-ha! so simple.

Thank you!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month