Hi all. I come from an MS SQL background and a newbie in MY SQL. Im trying to run a simple query to populate a table:

Declare @I As Int
Select @I = 1 

While (@I < 100)
  Insert into tbWhatEva
     Select @I

Select @I = @I + 1         

Why is it so hard to populate arbitrary data in a loop? Please tell me where Im going wrong.

Thank you

Recommended Answers

All 4 Replies

Does your table only have one column ? Did you try adding the column name to your insert query?

Hi pritaeas.

The porblem isnt the table structure. Its the loop. Ive just quoted MS SQL syntax as that's how to do it in MSSQL. I just want to run a simple insert query multiple times in a loop. Im now sure how to define the loop in a way that My SQL understands.

Thanks for the reply

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.