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 6597173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:10:31+00:00 2026-05-25T18:10:31+00:00

What is the PostgreSQL’s generate_series() equivalent in MySQL? How to convert this query to

  • 0

What is the PostgreSQL’s generate_series() equivalent in MySQL?

How to convert this query to MySQL?

select substr('some-string', generate_series(1, char_length('some-string')))

Sample output from PostgreSQL:

some-string
ome-string
me-string
e-string
-string
string
tring
ring
ing
ng
g

select generate_series(1, char_length('some-string'))

1
2
3
4
5
6
7
8
9
10
11

Final solution:

CREATE TABLE `numberlist` (
 `id` tinyint(4) NOT NULL AUTO_INCREMENT,
 PRIMARY KEY (`id`)
)

INSERT INTO `numberlist` values(null)
(repeat the above query the maximum string you need)

SELECT substr('somestring', id) 
FROM numberlist 
WHERE id <= character_length('somestring')
  • 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-25T18:10:31+00:00Added an answer on May 25, 2026 at 6:10 pm

    Here is the concept, but I don’t have mySQL installed on this box. You will need to create a table of integers, using AUTO INCREMENT. A table of numbers is generally a handy table to have available in a database, and would only need be created once

    create table NumberList (id MEDIUMINT NOT NULL AUTO_INCREMENT,fill char(1))
    
    declare @x INT
    set @x=0
    while @x < 20
    begin
        insert into numberList values(null)
        Set @x = @x+1
    end 
    

    Then, join this table as shown below using the LIMIT clause

    select substr('somestring',id) 
    from numberlist
    limit len('somestring')
    

    I wrote this in SQL server, but it shouldn’t be too difficult to convert to mySQL…

    The code below SHOULD work in mySQL

    DECLARE xx INT DEFAULT 0;
      WHILE xx < 20 DO
        insert into numberList values(null)        
        SET xx = xx + 1;
     END WHILE;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In PostgreSQL, there is this very useful string_agg function, that allows query like: SELECT
In postgresql a query in the querylog gets something like this: 2009-02-05 00:12:27 CET
Using PostgreSQL 8.4, I'm trying to put together the following query: SELECT (field_a +
With PostgreSQL and MySQL it is all right to do something like SELECT *
The following PostgreSQL text search select ID, DISPLAY_NAME, ts_rank_cd(to_tsvector('english', display_name), query) as RANK from
In PostgreSQL, how can I select some values into a 2D array? For example,
This PostgreSQL query solves my problem, but I'm not sure how to put it
In Postgresql 8 why this is ok select * from prod where code like
In Postgresql you can create additional Aggregate Functions with CREATE AGGREGATE name(...); But this
PostgreSQL stores statistics about tables in the system table called pg_class. The query planner

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.