php - MySQL Query for Advanced Search multiple criteria -


I am working through an advanced search query where users select the checkbox based on multiple criteria. I am starting because I am hoping that I will know whether I am on the right path. I know that the query is quite messy

Edit: I realized that there are two questions to be needed, so I have strictly modified a question question

table data

  tables ss_users user_id FIRST_NAME LAST_NAME admin_level user_approved 1 Nick Jones 0 1 2 Johnny Rocket 0 1 table ss_user_profile_status user_id photo_uploaded 1 1 2 1 table ss_user_photos selected user_id file name photo_id 1 1 photo_1 .jpg 1 2 2 photo_2.jpg 0 3 2 photo_2.jpg 1 table ss_general user_id city state zip neighborhood 1 Baltimore maryland 00125 hamsterdam 2 Lekland My 11542 treemont table ss_languages ​​user_id French German Italian Spanish 1 0 1 0 1 2 0 1 1 Table ss_experience Waldorf Kumon homeschooling user_id 1 0 1 0 2 0 0 1   

My current The result is that all users, which should not be the case: ...

  Select ss_users *, ss_user_profile_status *, ss_user_photos *, Ss_general. *, Ss_languages *, Ss_experience. * Join as Ss_users.user_id user ID, ss_user_profile_status.user_id, ss_languages.user_id as langI D ss_users from ss_users.user_id = ss_user_profile_status.user_id include Left ss_user_profile_status looking at ss_users.user_id = ss_user_photos.user_id ss_user_photos and ss_user_photos.selected = 1 on the left ss_users.user_id = ss_languages.user_id join ss_gers ss_users.user_id = ss_general at ss_general join ss_ganguages ​​.user_id LEFT JOIN ss_experience ss_users.user_id at ss_users.user_id where ss_users.user_id = ss_user_profile_status.user_id and ss_general.neighborhood_select Like '% hamsterdam%' or ss_languages.spanish = 1 or ss_experience.kumon = 1 and ss_users.sitter_approved = 1 and Ss_users.admin_level = 0 group ss_users.user_id DESC   

I need to represent most of the user profiles for production, so I am selecting a lot of table data, as well as getting additional

For your large fat SQL selection

  SELECT ss_users *, Ss_user_profile_status. *, Ss_user_photos. *, Ss_general. *, Ss_languages *, Ss_experience. * User ID, as ss_user_profile_status.user_id, ss_users.user_id = on ss_users.user_id Join the ss_languages.user_id as LangID Join ss_users ss_user_profile_status ss_users.user_id = ss_user_profile_status.user_id Left ss_user_photos ss_user_photos.user_id and ss_user_photos. Select = 1 on the left ss_users.user_id = ss_languages.user_id ss_languages ​​Join Join Left ss_gers at ss_users.user_id = ss_general.user_id on the left Join ss_users.user_id = ss_experience.user_id Where ss_experience (ss_general .neighborhood_select like '% hamsterdam% 'or ss_languages.spanish = 1 or ss_experience.kumon = 1) and ss_users.sitter_approved = 1 and ss_users.admin_level = 0   

Please add some places the bracket around the edited OR and remove the condition which remove even find it again milk, and the group as it will exit some data

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -