neddy Posted June 5, 2006 Share Posted June 5, 2006 i have a table setup with the following inidgame_idnamenow i want to filter/search the table for specific results so i did this[code]SELECT * FROM my_table WHERE name LIKE %$name% ORDER BY id DESC[/code]thats all well and good, i can use anything as $name and it returns all the rows with $name in name..now i want to filter them more so i try[code]SELECT * FROM my_table WHERE game_id = '1' OR game_id = '2' AND name LIKE %$name% ORDER BY id DESC[/code]it gives me results where name is nothing like $name ?any idea where im going wrong? or is there a better way to do what im trying to do?if i havnt explained what im trying to do very well then please say so and ill try to explain a bit better [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /] cheersEDIT: forgot to say if i just do [code]SELECT * FROM my_table WHERE game_id = '1' AND name LIKE %$name% ORDER BY id DESC[/code]it worksbut i want to be able to search for multiple game_ids... Quote Link to comment https://forums.phpfreaks.com/topic/11240-php-mysql-query-question/ Share on other sites More sharing options...
.josh Posted June 5, 2006 Share Posted June 5, 2006 [code]SELECT * FROM my_table WHERE game_id IN ('1','2','3') AND name LIKE %$name% ORDER BY id DESC[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11240-php-mysql-query-question/#findComment-42100 Share on other sites More sharing options...
neddy Posted June 5, 2006 Author Share Posted June 5, 2006 wow :Dworking perfectly so farthanks a bunch [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/11240-php-mysql-query-question/#findComment-42124 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.