Hiya,
I'm hoping to get some help/wisdom tossed my way...
Okay, I have three databases: GuysOnly, Ratings, and GirlsOnly.
I have a search-by-name script that queries the GuysOnly database & the Ratings database then returns the results sorted by rating, then by status, then by last name. This script works perfectly.
I want this same search-by-name script to query both the GuysOnly and the GirlsOnly databases and the Ratings database, then return all the results in both (ordered by rating, then by status, then by last name).
Can I have more than one JOIN statement? What would it look like? I'm really new to JOIN statements, and find them to be really confusing, so if someone can help out, that would be really great.
Here's my query statement thus far:
$query = "SELECT GuysOnly.id
, GuysOnly.LastName
, GuysOnly.FirstName
, GuysOnly.Phone1
, GuysOnly.city1
, GuysOnly.city2
, GuysOnly.city3
, GuysOnly.phone1
, GuysOnly.phone2
, GuysOnly.phone3
, GuysOnly.County
, GuysOnly.lastname
, GuysOnly.status
, COALESCE(ratings.comments, '') AS comments
FROM GuysOnly
LEFT JOIN ratings ON (ratings.id = GuysOnly.id)
WHERE (GuysOnly.LastName LIKE ('$ln%') AND GuysOnly.FirstName LIKE ('$fn%'))
GROUP BY GuysOnly.id
ORDER BY GuysOnly.status DESC, comments DESC, GuysOnly.lastname ASC";