mysql - 在magento 1.8.0.0版本中运行mysql复杂查询

标签 mysql magento

如何在magento 1.8.0.0中运行下面的mysql查询

select
    m.*,
    group_concat(c.store_id)
from
    news m
    join news_store c on find_in_set(c.news_id, m.news_id)
group by
    m.news_id

最佳答案

您可以执行以下操作:

$read = Mage::getSingleton('core/resource')->getConnection('core_read');

// now $write is an instance of Zend_Db_Adapter_Abstract
$read ->query("select m.*,
    group_concat(c.store_id)
    from
    news m
    join news_store c on find_in_set(c.news_id, m.news_id)
    group by
    m.news_id");

How to do custom query in magento?

关于mysql - 在magento 1.8.0.0版本中运行mysql复杂查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20467314/

相关文章:

javascript - 文本字段不应允许输入 6 个数字和数字

.htaccess - 通过在 .htaccess 中启用 gzip 来提高 magento 速度

mysql - 我怎样才能让 MySQL 记录预定的事件?

php - 扩展 Magento 的 EAV 属性模型

javascript - 单击图像按钮会增加购物车价格 - Magento

php - 如何使用 composer 安装 Magento2 示例模块?

php - 多个 php 函数实例

mysql - 如何更改MySQL的用户名和密码?

php - 多线程单连接中的 PDO::lastInsertId() 安全吗?

php - Doctrine :具有复合键的实体之间的 ManyToX 关系