0

So I have the current query:

UNION ALL SELECT 1,2,3,concat(username),5,6 FROM users LIMIT 0,1

I am aware that "LIMIT 0,1" only makes it show 1 result, but is it possible to make it show around 5 - 20 results at a time, so after I input the query I would want to get something like this:

username1, username2, username3, username4, username5

etc.. and when I run the query again (after modifying it of course), I would want to get something like:

username6, username7, username8, username9, username10

Thanks :)

  • The "union" and expected output look nothing alike due to what appears to be transposing columns and rows and/or confusing addition of `concat` aggregation. I suspect you may be interested in "pagination" instead of (or even combined with) a union, eg. https://stackoverflow.com/questions/3799193/mysql-data-best-way-to-implement-paging (it is possible to use `order by..limit..offset` with a derived table). – user2864740 Apr 30 '21 at 22:54
  • `UNION`joins the result set vertically a join vertically and provide a complete [mre] i dpn't understand what you want as result a comma separated list? – nbk Apr 30 '21 at 23:03
  • It's hard to understand exactly what you are asking. please do show the rest of your query, some sample data, and what results you want (for your series of queries) – ysth May 01 '21 at 00:06
  • This is presenting as an xy problem: 'how do I do x using y?', as opposed to 'how do I do x?' – Strawberry May 01 '21 at 08:26

1 Answers1

0

Are you after a comma separated list of usernames n long? If so, then try group_concat:

SELECT GROUP_CONCAT(username)
FROM (
    SELECT username
    FROM users 
    LIMIT 0,5
) z
Chris Strickland
  • 3,388
  • 1
  • 16
  • 18