Topic: 1 advanced query or a little the simple?
There are 3 tables:
users (id, type, online);
colors (id, name);
user_colors (user_id, color_id)
It will be necessary to receive sampling in which list of colors for users which online, and the type is equal to the set.
At me the algorithm about such turned out.
$result = SELECT * id FROM users WHERE type = $type AND online = true;
$result = SELECT * color_id FROM user_colors WHERE id = the array id which returns the first request
$result = SELECT * name FROM colors WHERE id = the array color_id which returns the second request
Whether it is possible it is all to make one request? An example please.
That it will be better from the point of view of productivity, such 3 requests or 1 big and terrible (if it is possible).
Correct errors in syntax, my variant all the same does not work.
The second request can/will return counterparts, whether it is possible to restrict it in request?