【问题标题】:i need to fetch records from one table where column value will be start with 'some value' and end with 'another some value'我需要从一个表中获取记录,其中列值将以“某个值”开头并以“另一个值”结尾
【发布时间】:2016-02-08 09:00:00
【问题描述】:
$nqry = mysql_query("select * FROM table_name where column_name BETWEEN 'AlertStopPressed' AND 'AlertStart'");
while($nftc = mysql_fetch_array($nqry)){
    echo $nftc['user_id']." - ".$nftc['alert_detail_id']." - ".$nftc['name']." - ".$nftc['alert_datetime']."<br>";
}

我必须对这些值进行分组。 please see the image for more details

【问题讨论】:

  • 使用groupByLimit
  • 感谢您的支持,但在这里我不能使用'groupBy',因为如果您看到图片,我想您会理解并请提供更好的解决方案。但最后我将不得不分组
  • 请注意,您使用的旧 mysql_* 扩展在 PHP 5.5 版(当前版本)中已弃用,并且正在从版本 7(下一个版本)中删除。您需要迁移到使用 mysqli_* 扩展或 PDO
  • 好的,谢谢你的建议。

标签: javascript php arrays multidimensional-array


【解决方案1】:
select * from table where columnname like 'startvalue%endvalue';

您的查询

$nqry = mysql_query("select * FROM table_name where column_name BETWEEN 'AlertStopPressed' AND 'AlertStart'") and columnname like 'startvalue%endvalue';

【讨论】:

  • tnx 为您的指示@sugumar 根据您的指示,我已提出此查询。但不工作 select * FROM alert_detail where (name BETWEEN 'AlertStopPressed' AND 'AlertStart') and (name like '%AlertStopPressed%' and '%AlertStart%')
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-21
  • 2020-11-15
相关资源
最近更新 更多