We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,595 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Getting multiple WHERE from a Previous Query

Hi so I'm making a site for sneakers. A person can sign up and say they like Nikes, Vans, Reeboks, etc.

I then have it where you can make a group for people who like certain sneakers as well. So the group can say they like Nikes, Vans, Reeboks, etc.

I want to get the group likes (Nikes, Vans, Reeboks, etc.) and search the users database for anyone who likes Nikes, Vans, or Reeboks.

I can get it where it searches only one like, but can't do it for multiple.

2
Contributors
5
Replies
5 Days
Discussion Span
7 Months Ago
Last Updated
6
Views
Question
Answered
thecameraman
Newbie Poster
15 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

|USER|LIKE|
______________
|JOHN| NIKE |
|JOHN| VANS |
|JOHN|REEBOKS|
|BRAD| NIKE |
|BRAD| VANS |
|BILL|REEBOKS|
|MIKE| NIKE |

|GROUP| TAGS|
______________
|GRO1| NIKE |
|GRO1| VANS |
|GRO1|REEBOKS|
|GRO2| NIKE |
|GRO2| VANS |
|GRO3| NIKE |

So The ADMIN for gro2 would see
John
Brad
MIKE

thecameraman
Newbie Poster
15 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

@thecameraman

Can you provide a Select & Where code so we can understand better.

LastMitch
Industrious Poster
4,118 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45
$links2 = "SELECT * FROM go_website_users 
LEFT JOIN go_users_activities_join ON (go_users_activities_join.user_id = go_website_users.ID) 
WHERE go_website_users.ID !='$uuserid' AND go_users_activities_join.activity_id = '$activityidee' 
ORDER BY friends DESC";

I want go_users_activities_join.activity_id = '$activityidee' to search all the group joined from the query below

$links = "SELECT * FROM sneaker_groups 
LEFT JOIN group_sneakers_join ON (group_sneakers_join.group_ID = sneaker_groups.ID) 
WHERE group_sneakers_join.activity_id = '$_GET['id']'";
thecameraman
Newbie Poster
15 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

@thecameraman

Read this Getting data from multiple tables - JOIN:

http://blogs.sakienvirotech.com/index.php/random/2011/09/09/mysql-101-retrieving-data-select

LastMitch
Industrious Poster
4,118 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

Thank you! The LEFT JOIN didn't work when I tried it but the JOIN worked!

thecameraman
Newbie Poster
15 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 7 Months Ago by LastMitch

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0725 seconds using 2.71MB