Mutiple selection menu/search
Posted: Sat Apr 10, 2004 5:39 pm
I'm storing values into database table in this way :
ROW1: user_id1 | 23,34,55,25
ROW2: user_id2 | 54,34,65
ROW3: user_id3 | 12
where these numbers are country codes stored in country field for certain members (user_id's) from a mutiple selection menu.
Now when i tried to search for members having those codes i used MySQL REGEXP for query, e.g.:
Actually this will slow down the process and will produce a huge query specially when i have lot of values need to be searched on.
So.. how usually multiple selection menu values should be stored into a database and the best way to search for those stored values?.
Regards..
Mishal
ROW1: user_id1 | 23,34,55,25
ROW2: user_id2 | 54,34,65
ROW3: user_id3 | 12
where these numbers are country codes stored in country field for certain members (user_id's) from a mutiple selection menu.
Now when i tried to search for members having those codes i used MySQL REGEXP for query, e.g.:
Code: Select all
while(...){
...
$pattern.="REGEXP('^".$country_codeї$i].",|,".$country_codeї$i].",|,."$country_codeї$i]."$|^."$country_codeї$]."$')";
..
}
$query="SELECT .. FROM .. WHERE ".$pattern;So.. how usually multiple selection menu values should be stored into a database and the best way to search for those stored values?.
Regards..
Mishal