Welcome Guest, Not a member yet? Register   Sign In
SEARCH HELP
#1

[eluser]napz[/eluser]
Hi Guys,

I have a question for searching, for example we have two different table the hero table and the skills table.

1. in skills table we have 3 columns skill_id, hero_id(foreign key), and skill_name, so we can put as many skills to each hero
2. in hero table we have 2 columns hero_id and hero_name

example data :

hero table
-------------------------
hero_id | hero_name
1 | alex
2 | hector



skills table
-----------------------------------------
skill_id | hero_id |skill_name
1 | 1 |Fast
2 | 1 |Strong
3 | 1 |Flying
4 | 2 |X-ray eyes
5 | 2 |Flying
6 | 2 |Fast



If I search for Heroes name who have the skill_name like Fast and Strong.
The output will be
alex and hector
wherein the hero_name alex will not be duplicated because he has a fast and strong skills.
How can I do that? (search for multiple skill_name but the output of hero will be only once)
#2

[eluser]danmontgomery[/eluser]
Code:
GROUP BY hero.hero_id

or

Code:
$this->db->group_by("hero.hero_id");




Theme © iAndrew 2016 - Forum software by © MyBB