I'm still new at this, but struggling on slowly. I have a table in my db that details the characters in my WoW guild (sad, I know). The table has the following columns:
ID - primary key, auto increment, etc, etc
char1 - the character name
rank - characters guild rank
class - their class
max_lvl - yes/no to if they are max level
spec1 - their primary spec
spec2 - their secondary spec
role1 - the role defined by spec1, like tank, healer, etc
r1eg - yes/no to is the role 1 gear end-game level
role2 - the role defined by spec2
r2eg - yes/no to is the role 2 gear end game level
What I want to be able to do is search for (for example) all characters that are max level, have a tank spec, and that spec is end game geared.
I can do the form to post to a script, but have no clue how to go about this sort of search query. Could anybody point me in the right direction please?
Regards,
Balveda
How to search multiple fields?
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: How to search multiple fields?
SELECT * FROM characters WHERE max_lvl='yes' AND role1='tank' AND r1eg='yes'
(#10850)
Re: How to search multiple fields?
Thanks dude, but how would I include the role2 and r2eg? As these could also hold the data that is being searched for.Christopher wrote:SELECT * FROM characters WHERE max_lvl='yes' AND role1='tank' AND r1eg='yes'
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: How to search multiple fields?
For example, if you wanted records where either role was tank then.
SELECT * FROM characters WHERE max_lvl='yes' AND ((role1='tank' AND r1eg='yes') OR (role2='tank' AND r2eg='yes'))
This is logic, so you should play with combination to what they give you.
SELECT * FROM characters WHERE max_lvl='yes' AND ((role1='tank' AND r1eg='yes') OR (role2='tank' AND r2eg='yes'))
This is logic, so you should play with combination to what they give you.
(#10850)
Re: How to search multiple fields?
Thank you very much. I'm still struggling to get my head round mysql/php. I'll work on the script tonight and see how I get on 