Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6047809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:23:35+00:00 2026-05-23T07:23:35+00:00

I have a query that returns as a result what seems to be a

  • 0

I have a query that returns as a result what seems to be a BLOB

SELECT CAST(GROUP_CONCAT(CONCAT(value,'(',qty,')') SEPARATOR ', ') AS CHAR)a 
FROM ( 
   SELECT value,count(*) qty 
     FROM extra_field_values 
    WHERE fieldid = @fieldid 
      AND value != '' 
      AND itemid IN (7,8,10,12,15,16,17,18,19,20,21,22,23,24,25,26) 
   GROUP BY value
) x 

the table is

CREATE TABLE `extra_field_values` (
   `itemid` int(11) NOT NULL DEFAULT '0',
   `fieldid` int(11) NOT NULL DEFAULT '0',
   `value` text NOT NULL,
   KEY `itemid` (`itemid`),
   KEY `fieldid` (`fieldid`),
   KEY `value` (`value`(1)),
   KEY `inx` (`itemid`,`fieldid`,`value`(1))
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

The main idea is that i want a string per row returning value:::count separated by ###.

The problem is that php returns empty result. I have tried both mysql and mysqli as far as drivers is concerned.
Any ideas?

PHP

$result = $mysqli->query("    SELECT CAST(GROUP_CONCAT(CONCAT(value,'(',qty,')') SEPARATOR ', ') AS CHAR)a 
FROM ( 
   SELECT value,count(*) qty 
     FROM extra_field_values 
    WHERE fieldid = @fieldid 
      AND value != '' 
      AND itemid IN (7,8,10,12,15,16,17,18,19,20,21,22,23,24,25,26) 
   GROUP BY value
) x ") ;
    while( $row = $result->fetch_assoc() ){ 
        print_r($row);
    }

Even if you execute it through phpmyadmin it returns null. Try it on EMS mysql it works like a charm.

full query

SELECT 
extra_field_values.fieldid,
extra_fields.var_name,
extra_fields.field,
extra_fields.type,
@fieldid:=extra_field_values.fieldid, 
( 
 SELECT CAST(GROUP_CONCAT(CONCAT(value,'(',qty,')') SEPARATOR ', ') AS CHAR) a 
 FROM ( SELECT value, @fieldid, count(*) qty FROM extra_field_values WHERE fieldid = @fieldid GROUP BY value ) x 
) as v,
count(itemid) as total,
(SELECT groupid FROM extra_fields_groups_items WHERE itemid = @fieldid) as groupid 
FROM extra_field_values INNER JOIN extra_fields 
  ON (extra_field_values.fieldid=extra_fields.fieldid) 
WHERE module = 'listings' 
 AND itemid IN (7,8,10,12,15,16,17,18,19,20,21,22,23,24,25,26) 
 AND settings LIKE '%"search";s:1:"1"%' 
GROUP BY fieldid
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:23:35+00:00Added an answer on May 23, 2026 at 7:23 am

    You are querying for fields matching the session variable @fieldid but I would guess you’re not defining that variable in your mysqli session or in your phpmyadmin environment.

    SET @fieldid := 1234;
    SELECT ... WHERE fieldid = @fieldid ...
    

    Or else you can use ? as a query parameter placeholder for the fieldid and bind it to a PHP variable.

    See http://php.net/manual/en/mysqli-stmt.bind-param.php


    Does the following query do what you want, without using the @fieldid session variable?

    SELECT x.fieldid, x.var_name, x.field, x.type, x.groupid, COUNT(*) AS total,
      CAST(GROUP_CONCAT(CONCAT(x.value,'(',x.qty,')') SEPARATOR ', ') AS CHAR) a 
    FROM ( 
      SELECT v.value, v.fieldid, f.var_name, f.field, f.type, g.groupid, COUNT(*) AS qty 
      FROM extra_field_values AS v
      INNER JOIN extra_fields AS f ON f.fieldid=v.fieldid
      INNER JOIN extra_fields_groups_item AS g ON g.itemid=v.fieldid
      WHERE f.module = 'listings'
       AND f.itemid IN (7,8,10,12,15,16,17,18,19,20,21,22,23,24,25,26) 
       AND f.settings LIKE '%"search";s:1:"1"%' 
      GROUP BY v.value, v.fieldid
      ) as x
    GROUP BY x.fieldid
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL query that returns a result with a single column of
Say I have a stored procedure that returns data from a SELECT query. I
i have a query that returns ~50k rows, seems like doctrine put this whole
I have an asp:datasource select query that returns a sum. I want to assign
I have a dynamic query that returns around 590,000 records. It runs successfully the
I have a MySQL (v 5, MyISAM) query that returns different rows depending on
I have a query that originally looks like this: select c.Id, c.Name, c.CountryCode, c.CustomerNumber,
I have a query that looks like this: select id , int1 , int2
I have a long running query that returns a large data set. This query
I have a DataSet that I fill with a SQL select query. I then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.