PHP Query with a multiple resoruces (results) to a one string?

Im trying to get a (multiple) results - resources actually from one Query, ready to be exploded(). I did it troughout while() command, but its quite complicated. All I need is resources.

Like "SELECT id FROM..." what are 1,2,3,4,5...

to output like this..

1,2,3,4,5

Can this be done?

Thanks!

-------------Problems Reply------------

You can do it by using group_concat in your query.

SELECT group_concat(id) as id FROM....

http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat

use GROUP_CONCAT() function

see this link http://mahmudahsan.wordpress.com/2008/08/27/mysql-the-group_concat-function/

Category:php Views:0 Time:2010-12-22
Tags: php

Related post

  • Big Mysql Query (Join counts in the result and modify a string) 2014-10-08

    I am brand new to mysql so please excuse my level of knowledge here, and feel free to direct me in a better direction if what I am doing is out of date. I am pulling information from a database to fill in a php page. My tables: Server: |ServerID (int

  • Access 2007, Would like to use multiple row results from a subform in a query but can only pull one record at a time. 2012-09-25

    New to VB......I have a designed a form in Access 2007 using multiple list boxes from a single table. Using VB I have set up the boxes to allow users to select multiple values from multiple boxes to generate a subform listing the details meeting the

  • Disadvantages of MARS (Multiple Active Result Sets)? 2008-12-17

    Does anyone know of any disadvantages of MARS (Multiple Active Result Sets)? Does anyone know of any reason why one should avoid using MARS, like cases where cursors are more useful then MARS. --------------Solutions------------- There are apparently

  • Why is this query faster with multiple selects rather than using between? 2009-05-14

    I have a table in Sql Server 2008 Express which contains 18 million records. The structure looks something like this (simplified): Id, GroupId, Value, Created Id is the primary key with a clustered index GroupId is a non-clustered index In this case,

  • JPA: Query that returns multiple entities 2011-07-29

    I'm writing a JPQL query that joins across three tables. In my resultlist I would like to get all three entities per matching row (hope that makes sense). Any ideas? Hibernate 3.x is my JPA provider. --------------Solutions------------- IIRC, you can

  • Query doesn't provide expected results - not sure what to try next 2014-03-31

    I have a built a query that pulls information from three different tables. It's fairly straightforward - except for one thing. In one of my tables (CaregiverFamily) I have the option to include more than one caregiver record per participant (the main

  • Internet multiple search results? 2014-04-15

    Can Windows 7 display multiple search results simultaneously? It only seems to show the last query. --------------Solutions------------- Can Windows 7 display multiple search results simultaneously? Wrong forum. E.g. try W7 Files Folders and Search.

  • Distributed Queries and Multiple Active Result Sets (MARS) not supported in memory optimized tables 2014-04-16

    I have the below query (as stored procedure ) which I like to fire it from an app (Written by C# ) against SQL server 2014 , also I should mention that dbo.tbl_vwPlanningSalesProc is a memory optimized table! by the wayI already disabled the "Multipl

  • ERROR: query has no destination for result data 2010-01-18

    CREATE OR REPLACE FUNCTION _chkLogin(userid varchar, pwd varchar) RETURNS BOOLEAN AS $BODY$ DECLARE passed BOOLEAN; BEGIN SELECT (_password = $2) FROM _vRegistration WHERE _userid = $1; RETURN passed; END; $BODY$ LANGUAGE 'plpgsql'; When am executing

  • Query has no destination for result data after Trigger 2010-04-30

    i have a problem with me trigger. Every time i insert a new line i will check if the article not sold. I can do it in the software but i think its better when the DB this does. -- Create function CREATE OR REPLACE FUNCTION checkSold() RETURNS TRIGGER

  • Multiple "Occur" result buffers in emacs? 2011-03-28

    Is there a package that allows me to have multiple Occur result buffer for the same buffer (like grep-a-lot: http://www.emacswiki.org/emacs/grep-a-lot.el). I run into this issue when analyzing log files for multiple keywords (say to see what differen

  • Deserializing multiple JSON result with JavaScriptSerializer 2011-03-30

    I'm trying to deserialize sample JASON at the end of this question with below. But results.count is always 0. how can i deserialize this JSON with multiple data so i can loop with foreach (Foo r in results) { Response.Write(r.html); } [Serializable()

  • MVC3 action filter attribute with execution of multiple action results 2011-06-15

    I would like to know if its possible to execute few actionresults as a result of an action filter. filterContext.Result=execution of few actionresults My problem is that i have to render the view of my action depending on some user credentials or one

  • How to get the average of a nested query returned as a single result based on the parent query 2011-10-11

    Here is another problem I have had to deal with in the last couple of days. I have the following query: SELECT S.Name,S.Surname,S.Student_ID,S.StudentNumber,C.Course, B.Campus_Title,M.Module,SM.Percentage_Obtained,S.Days_Absent FROM Students S INNER

  • memcached multiple mysql results 2011-11-03

    I'm trying to set up memcached to store the results of the query that pulls all the data to be shown on my front page. when i use memcached for one result it works fine, but when I set the query to 'LIMIT 10' and pull the cache it still only shows on

  • PostgreSQL error: query has no destination for result data 2012-02-17

    Trying to get into PostgreSQL. I'm drawing an function that will check credentials Here is it: CREATE or REPLACE FUNCTION CkeckUser (Login varchar(50), Password varchar(50)) RETURNS TABLE(ID int, IDParent int, Text varchar(50), Image bytea, DLLName v

  • LINQ to SQL query has wrong values in results 2012-02-23

    I have a LINQ query that has the incorrect results, but when I profile the SQL generated, the SQL results are correct. ApplicationsEntities context = new ApplicationsEntities(); var query = from documentation in context.Documnetations where documenta

  • Hibernate criteria query is returning me stale results 2012-03-13

    I have a simple table ApplicationLog in Hsqldb 1.8.0 A seperate client inserts data into this table. I am querying this table from another java client. I find that the criteria query count is not correct if this querying java client is left running.(

  • Don't return any result if the precedent query has at least 1 result? 2012-04-28

    Basically I have this query: ( SELECT * FROM tbl WHERE type = 'word1' ) UNION ( SELECT * FROM tbl WHERE type = 'word2' ) // Run this query if there are no results with type = 1 Basically I would like to run the second query only if the first hasn't a

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.071 (s). 11 q(s)