My Sql skills are lacking and would really appreciate the help. What is the most efficient way to pull all records where a field is the same?
For example my tables name is ‘games’ and has an association with the table ‘consoles’
How do I pull all record of games with the same (duplicate) ‘name’, retain associations and be able to access all fields.
Basically modify this to just show duplicates:
$this->set('games', $this->Game->find('all', array('order' => array('Game.name' => 'asc'))));
Is there an easy way to do this using cake or how would I do it through sql using query()?
Much appreciated in advance!
Regards,
Ash
Tried to use Konerak query, it worked but only on small tables, on my test base with 2k records it crashed on sql client and gives a memory error on php (I used a non indexed field for testing). If it works for you:
/*
This solutions use 2 queries but I managed to test it just fine:
Let me know if that won’t work for you and what problems you are having.
edit. I commented the
containlines. Seems you want all the structure so you wouldn’t need them anyway.edit2. remove possible ambiguity on field names.