QUESTION ABOUT SELECT * FROM

0

good morning, my question is this, I'm experimenting with database, and I have only 1 record in the database and I show it by the following:

SELECT * FROM tabla

very well, following this shows me only the record I have, how do I repeat that same record say 5 times? .. that is to double 5 times instead of showing me only 1 which is by default .. thanks

    
asked by Rick 09.02.2017 в 20:39
source

2 answers

2

I did not understand your question very well, but at least in Postgres I would do it like this:

SELECT 
    a.*
FROM
    (
         SELECT * FROM tabla
    )a
CROSS JOIN

    (   
        SELECT generate_series(1, 3)
    )b;

Anyway, I think what you want to do happens more for PHP than for SQL.

    
answered by 09.02.2017 в 20:50
1

You can print the result of the query 5 times, however as I said it does not make sense to show the information again, since you only have one record in the table.

DECLARE @counter INT;
SET @counter = 0;

WHILE @counter < 5
BEGIN
   SELECT * FROM tabla
   SET @counter = @counter + 1;
END;

this is similar to:

 SELECT * FROM tabla
 SELECT * FROM tabla
 SELECT * FROM tabla
 SELECT * FROM tabla
 SELECT * FROM tabla

The question would be, what is the purpose of this.

    
answered by 09.02.2017 в 21:07