MySQL类别名称而不是数字

发布于 2025-01-26 08:09:09 字数 1793 浏览 3 评论 0原文

我从数据库中获取一些运作良好的内容。类别的输出在数值上用逗号分隔,我正在寻找一种用相应的类别名称替换这些数字的方法。

sql语句:

    SELECT
    p.products_id as ArtID,
    p.products_model as Artikelnummer,
    p.products_id as ArtID,
    p.products_ean as EAN,
    p.products_sort as "Master Sort",
    p.products_master_slave_order as "Int. Sort",
    d.products_name as Artikelname,
    d.products_short_description as Kurzbeschreibung,
    d.products_description as Beschreibung,
    CONCAT("https://127.0.0.1/",u.url_text) as url_text,
    FORMAT(p.products_vpe_value,0,'de_DE') as products_vpe_value,
    CONCAT(FORMAT(p.products_price,2)," EUR") as "VK Netto",
    FORMAT(p.products_weight,3) as Gewicht,
    p.products_shippingtime as Lieferzeit,
    CONCAT("https://127.0.0.1/media/images/info/",p.products_image) as Bild1,
    GROUP_CONCAT(c.categories_id ORDER by 'p.products_id' SEPARATOR ',') as Kategorie,
    p.products_status as Status,
    p.disabled_shippings as Spedition,
    d.products_keywords as "Keyword Suche",
    u.meta_title as "Meta Title 55-60",
    u.meta_description as "Meta Description 150"
FROM
    xt_products p
    left join xt_products_description d on p.products_id = d.products_id
    left join xt_products_to_categories c on p.products_id = c.products_id
    left join xt_seo_url u on p.products_id = u.link_id AND u.link_type = 1
GROUP BY p.products_id
ORDER BY `ArtID` ASC

line” group_concat(c.categories_id order by'p.products_id'sapeator','')作为kategorie'创建您在pic中看到的数字。类别的名称在表Xt_categories_description> categories_id + categories_name。

有什么方法是,784,783,782可以成为CATA,CATB,CATC ...

谢谢您的帮助。

I take from a database some stuff that work well. The output of the categories is numerically separated with a comma, I am looking for a way to replace these numbers with the corresponding category names.

enter image description here

The sql statement:

    SELECT
    p.products_id as ArtID,
    p.products_model as Artikelnummer,
    p.products_id as ArtID,
    p.products_ean as EAN,
    p.products_sort as "Master Sort",
    p.products_master_slave_order as "Int. Sort",
    d.products_name as Artikelname,
    d.products_short_description as Kurzbeschreibung,
    d.products_description as Beschreibung,
    CONCAT("https://127.0.0.1/",u.url_text) as url_text,
    FORMAT(p.products_vpe_value,0,'de_DE') as products_vpe_value,
    CONCAT(FORMAT(p.products_price,2)," EUR") as "VK Netto",
    FORMAT(p.products_weight,3) as Gewicht,
    p.products_shippingtime as Lieferzeit,
    CONCAT("https://127.0.0.1/media/images/info/",p.products_image) as Bild1,
    GROUP_CONCAT(c.categories_id ORDER by 'p.products_id' SEPARATOR ',') as Kategorie,
    p.products_status as Status,
    p.disabled_shippings as Spedition,
    d.products_keywords as "Keyword Suche",
    u.meta_title as "Meta Title 55-60",
    u.meta_description as "Meta Description 150"
FROM
    xt_products p
    left join xt_products_description d on p.products_id = d.products_id
    left join xt_products_to_categories c on p.products_id = c.products_id
    left join xt_seo_url u on p.products_id = u.link_id AND u.link_type = 1
GROUP BY p.products_id
ORDER BY `ArtID` ASC

The line "GROUP_CONCAT(c.categories_id ORDER by 'p.products_id' SEPARATOR ',') as Kategorie" create the numbers you see in pic. The names of the Categories is in table xt_categories_description > categories_id + categories_name.

Is there a way that instead 784,783,782 can become CatA, CatB, CatC ...

Thank you for help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文