It's too bad that ON (column = column) comes after and not before INNER JOIN table, because if it came before it would make for much cuter code formatting:
SQL:
-
SELECT DISTINCT $columns
-
FROM
-
$this->comments
-
ON (comment_post_ID = post_id) INNER JOIN
-
$this->post2cat
-
ON (category_id = cat_ID) INNER JOIN
-
$this->categories
-
WHERE
-
blog = '$blog' AND
-
$criteria
ShareThis
Arrrrre you readyyyyy--- for an es Q elllllllll--- CHALLENGE!!!!!
I have a user table, let's say with name and zipcode. I can do the following successfully:
- Select a random user with
SELECT * FROM users ORDER BY RAND(UNIX_TIMESTAMP()) LIMIT 1
- Select all users, with only 1 from each zipcode, using
SELECT * FROM users GROUP BY zipcode update: I simplified this as per Danny's suggestion below
The only problem is, in case 2, it's always the same user per-zipcode. I want to randomize which in the grouping gets pulled out. I would prefer that the solution not involve joining the table on itself, although if I don't find another solution I will probably whip up the self-join solution just for fun.
ShareThis