Some thoughts from a beginner about a mysql-query.
Lets say i need some new fields for xf_user.
Which colors do you like?
red, green, blue, yellow, grey, orange
1. I could add now some fields like:
xf_user.red
xf_user.green
xf_user.blue
xf_user.yellow
(or color1, color2, color3)
select * from xf_user where red = 1 AND green=1
but we dont like to have so many new fields here.
2. I could add a textfield
xf_user.colors with value "greenbludyellow"
select * from xf_user where colors like %green% and colors like %yellow%
because this will not fit, we need to save
xf_user.colors with value "xgreenbludyellowx" (else green will not be found with %green%! Also %yellow% will not be found!)
3. Also i could have a list like
red = 1
green = 2
blue = 3
yellow = 4
xf_user.colors with value ".23."
select * from xf_user where colors like %2% OR colors like %3%
4. Should i think about to save bits for the search with "AND"?
red = 1
green = 2
blue = 4
yellow = 8
red, yellow => 1+8 = 9
to search for red and yellow
select * from xf_user where colors = 9
what is better than
select * from xf_user where colors like %1% AND colors like %8%
for the search with AND this makes sense to me, but what is with a search with OR?
to find red or yellow we have to query for
select * from xf_user where colors = 1 OR colors = 8 OR colors = 9
but with as an example eight values/bits we have a lot of "OR" and many combinations (255), then it is maybe better just to query:
select * from xf_user where colors like %1% OR colors like %2% OR ... colors like %9%
Is there anything else much better to use for a query with AND and/or OR?
bits for select-field
text with like %x% for radio-field?
Lets say i need some new fields for xf_user.
Which colors do you like?
red, green, blue, yellow, grey, orange
1. I could add now some fields like:
xf_user.red
xf_user.green
xf_user.blue
xf_user.yellow
(or color1, color2, color3)
select * from xf_user where red = 1 AND green=1
but we dont like to have so many new fields here.
2. I could add a textfield
xf_user.colors with value "greenbludyellow"
select * from xf_user where colors like %green% and colors like %yellow%
because this will not fit, we need to save
xf_user.colors with value "xgreenbludyellowx" (else green will not be found with %green%! Also %yellow% will not be found!)
3. Also i could have a list like
red = 1
green = 2
blue = 3
yellow = 4
xf_user.colors with value ".23."
select * from xf_user where colors like %2% OR colors like %3%
4. Should i think about to save bits for the search with "AND"?
red = 1
green = 2
blue = 4
yellow = 8
red, yellow => 1+8 = 9
to search for red and yellow
select * from xf_user where colors = 9
what is better than
select * from xf_user where colors like %1% AND colors like %8%
for the search with AND this makes sense to me, but what is with a search with OR?
to find red or yellow we have to query for
select * from xf_user where colors = 1 OR colors = 8 OR colors = 9
but with as an example eight values/bits we have a lot of "OR" and many combinations (255), then it is maybe better just to query:
select * from xf_user where colors like %1% OR colors like %2% OR ... colors like %9%
Is there anything else much better to use for a query with AND and/or OR?
bits for select-field
text with like %x% for radio-field?