homepage Welcome to WebmasterWorld Guest from 54.204.249.184
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
newbie query
OR statement?
discord




msg:4159508
 8:47 pm on Jun 25, 2010 (gmt 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!

 

LifeinAsia




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

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




msg:4159513
 8:54 pm on Jun 25, 2010 (gmt 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]

discord




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

a-ha! so simple.

Thank you!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved