mysql php group_concat限制条款如何仅获取3-4条记录(数量有限)

时间:2015-08-01 11:29:14

标签: php mysql

我想在下面提到的查询中仅获取有限的行输出,请帮助

$sql12 = "SELECT group_concat(concat(firm_name, '- ',city,', ',mobile,'.') SEPARATOR ' ') as Result FROM  reg_dealer WHERE pincode = '$myvalue'";
$q12 = mysql_query($sql12);
$rows12= mysql_num_rows($q12);
while($res12= mysql_fetch_array($q12))
{
$res12['Result'];
$mobile = $_GET['mobile'];
$reply_message = "Greetings. Please find the nearest Partner - ".$res12['Result']."";

1 个答案:

答案 0 :(得分:0)

尝试此代码

 $sql12 = "SELECT group_concat(concat(firm_name, '- ',city,', ',mobile,'.') SEPARATOR ' ') as result FROM (select * FROM reg_dealer WHERE pincode = '$myvalue' LIMIT 0, 3) as data";
    $q12 = mysql_query($sql12);
    $rows12 = mysql_num_rows($q12);
    while($res12= mysql_fetch_array($q12))
    {
         $res12['Result'];
         $mobile = $_GET['mobile'];
         $reply_message = "Greetings. Please find the nearest Partner - ".$res12['Result']."";
    }