_giles_ Posted February 20, 2008 Share Posted February 20, 2008 Hi I'm working on a query where I'd like to be able to search one OR two attributes. I've come accross a few postings that lead me to the code below. It works fine if I put something in both attributes but fails if I leave the second blanc. Can you help? SELECT * FROM books WHERE title LIKE '%$title%' AND title_sub LIKE '%$title_sub%' ORDER_BY print_id (I would ideally like to make the first attribute optional. I may also want to add a few more attributes later) Quote Link to comment https://forums.phpfreaks.com/topic/92133-multiple-queries/ Share on other sites More sharing options...
fenway Posted February 20, 2008 Share Posted February 20, 2008 This generally has to be done at the application level, where you build your where clause .. but in this case, it should evaluate to %% if blank, which although slow, shouldn't "fail". Quote Link to comment https://forums.phpfreaks.com/topic/92133-multiple-queries/#findComment-471854 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.