如何使用MYSQL进行多列搜索? [英] How to do multiple column search using MYSQL?
问题描述
i有8个字段
性别:新娘新郎
年龄:从到
身高:从To
宗教:
婚姻状况:
城市:
州:
国家:
搜索按钮。
我想要一个搜索查询来获取价值这些字段和搜索根据。
,如果有人想要只有两个字段或3个字段等搜索,他和她可以得到结果。
我用过这些代码但是没有得到确切的结果。
Hi,
i have 8 fields as
Gender: Bride Groom
Age : From To
Height: From To
Religion:
Marital Status:
City:
State:
Country:
Search button.
I want a search query for this which take value from these fields and search according.
like if anyone want a search with only two fields or 3 fields etc etc he and she can get result according.
I have used these code but yet not get the exact result.
Is Query 1 in correct format?
Query 1:
$query_for_result=mysql_query("select * from matri_user_info where (gender='$gender') and if($agemin='' and $agemax='') then (age between 18 and 100 )else (age between $agemin and $agemax) and if($hmin='' and $hmax='')then (height between 0 and 7 else (height between $hmin and $hmax) and if(religion='')then (religion !='') else(religion='$religion') and if (marital_status='')then (marital_status !='')else (marital_status='$marital_status') and if((city ='') then (city !='') else (city ='$city') and if (state='')then (state !='')else (state='$state') and if(country='')then(country !='') else(country='$country');");
Query 1:
SELECT *FROM pages WHERE MATCH(gender, age,height,religion,marital_status,city,state,country) AGAINST ('$gender','between $agemin and $agemax','between $hmin and $hmax','$religion','$marital_status','$city','$state','$country' IN BOOLEAN MODE)
Query 3:
$query_for_result=mysql_query("select * from matri_user_info where (gender='$gender') or (age between $agemin and $agemax) or (height between $hmin and $hmax) or (religion='$religion') or (marital_status='$marital_status') or (city ='$city') or (state='$state') or (country='$country');");
Query4:
$query_for_result=mysql_query("select * from matri_user_info where (gender='$gender') and (age between $agemin and $agemax) and (height between $hmin and $hmax) and (status='unlock');");
如果有人有这方面的答案?请与我分享,我很长时间都在寻找这个。
谢谢
If anyone has the answer for this? Please Share with me, i am searching for this since long.
Thanks
推荐答案
query_for_result = mysql_query ( select * from matri_user_info where(gender ='
query_for_result=mysql_query("select * from matri_user_info where (gender='
gender')和if(
gender') and if(
agemin =''和
agemin='' and
这篇关于如何使用MYSQL进行多列搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!