Just done a quick test. This seems to work.
Just done a quick test. This seems to work: mysql> select * from categories c, items I -> where i. Categoryid = c.Id -> group by c.
Id; +------+---------+------+------------+----------------+ | id | name | id | categoryid | name | +------+---------+------+------------+----------------+ | 1 | Cars | 1 | 1 | Ford | | 2 | Games | 4 | 2 | Tetris | | 3 | Pencils | 6 | 3 | Pencil Factory | +------+---------+------+------------+----------------+ 3 rows in set (0.00 sec) I think this would fulfil your first question. Not sure about the second one - I think that needs an inner query with order by random() or something like that!
Having the results being random isn't that important to me, so this was really what I was looking for! Thanks – Eikern Oct 2 '08 at 16:06.
Mysql lets you to have columns not included in grouping or aggregate, in which case they've got random values: select category. Id, category. Name, itemid, itemname inner join (select item.
Categoryid, item. Id as itemid, item. Name as itemname from item group by categoryid) on category.Id = categoryid Or, for minimums, select category.
Id, category. Name, itemid, itemname inner join (select item. Categoryid, min(item.
Id) as itemid, item. Name as itemname from items group by item. Categoryid) on category.
Id = categoryid.
I got an error when I tried this method: "Every derived table must have its own alias". I guess I did something wrong somewhere. – Eikern Oct 2 '08 at 16:22.
Mysql does let include non aggregate columns and there is no guarantee of determinism, but in my experience I nearly always get the first values. So usually (but not guaranteed) this will give you the first select * from categories c, items I where i. Categoryid = c.Id group by c.
Id; If you want guaranteed you will need to do something like select categories. Id, categories.Name, items. Id, items.
Name from categories inner join items on items. Categoryid = categories. Id and items.
Id = (select min(items2.Id) from items as items2 where items2. Categoryid = category. Id) If you want random answers you will have to change the subquery a little bit select categories.Id, categories.
Name, items. Id, items.Name from categories inner join items on items. Categoryid = categories.
Id and items.Id = (select items2. Id from items as items2 where items2. Categoryid = category.Id order by rand() limit 1).
Mysql lets you to have columns not included in grouping or aggregate, in which case they've got random values.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.