I have a mysql query that looks like this:
$query = "SELECT * FROM users
JOIN signup ON users.uid = signup.uid
JOIN jobs ON users.category_id = jobs.id
JOIN lclasses ON users.class = lclasses.class_id
JOIN degrees ON users.degree_id = degrees.degree_id
JOIN trades ON users.trade_id = trades.trade_id
JOIN tradestatuses ON users.trade_status = tradestatuses.status_id
WHERE users.uid='{$id}' LIMIT 1";
If $id = 8, then my query returns properly. If I try any other id that’s in my database, I get an empty result set.
I tested the query in phpMyAdmin and get the same result. No errors in the query when I use the different numbers, just an empty result set yet I can look at the row right in the Browse section. Is my table corrupted? Anybody had anything like that ever happen to them?
An empty result set is an empty result set.
Since they are all INNER JOINS, any one of the joins could be “linking to nothing” (and thus resulting an empty result set). It is impossible to say more without careful inspection of the data. I would consider breaking the query down into parts to see which part “doesn’t work”.
Happy coding.
Helpful advice from mu’s post comment: