Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > Database & Database Programming

Database & Database Programming MySQL, Oracle, SQL, PL/SQL, ABAP, Smart Forms, and other databases and languages. A database is an organized body of related information used in many websites (including CC).

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-04-2007, 10:12 AM
reachpradeep's Avatar   
reachpradeep reachpradeep is offline
Learning Programmer
 
Join Date: Mar 2007
Location: India
Posts: 41
Rep Power: 7
reachpradeep is on a distinguished road
Send a message via MSN to reachpradeep
Default MySQL Loops

Hello,

I'm trying to create some loops inside my sql statements for some data migration. I have setup the following SQL statement to test out my syntax but keep recieving errors. Here are the ones I tried:

Code:
USE favoriteagent;
SELECT @totrows := COUNT(Customerid) FROM agents;
SET @count := 0;
REPEAT
  SELECT * FROM agents WHERE (Customerid = @count);
  SET @count := (@count -1);
UNTIL (@count := 0) END REPEAT;
And:

Code:
USE favoriteagent;
SELECT @totrows := COUNT(Customerid) FROM agents;
SET @count := 0;
WHILE (@count < @totrows) DO
  SELECT * FROM agents WHERE (Customerid = @count);
  SET @count := (@count -1);
END WHILE;
Everytime I recieve the following errors:

(using repeat)
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'REPEAT
SELECT * FROM agents WHERE (Customerid = @count)' at line 1


(useing while)
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHILE (@count < @totrows) DO
SELECT * FROM agents WHERE (Customerid = @count)' at line 1

How I do a loop?

Thanks in advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MYSQL CheatSheet - A must for MySQL Users reachpradeep Database & Database Programming 1 03-03-2007 04:05 PM
JavaScript:Tutorial, Loops TcM Javascript 4 12-13-2006 09:53 AM
Toad for MySQL Lop Database & Database Programming 0 12-06-2006 12:07 PM
Toad for MySQL 2.0.1 Kernel Software Development Tools 0 10-03-2006 07:03 AM
MySQL Resources dirkfirst Database & Database Programming 1 05-25-2006 03:31 AM


All times are GMT -5. The time now is 12:38 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 98%

Ads