Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 13-07-2009
Member
 
Join Date: May 2009
Posts: 22
How to create loop query sql ?

I want to retrieve emails in a text file and insert these emails in SQL queries to deal with.

Code:
Here is my case: 
  $ fp = fopen ( "$ file", "r") / / We open the file 

  while (! feof ($ fp))  
  (  
  $ line = fgets ($ fp, 255) / / It gets the lines of the file (emails ..) 

  mysql_query ( "UPDATE members SET email = NULL WHERE email = '$ line'"); 

  echo $ line. '<br />'; 
  )
Problem is that above query does not work. emails are not deleted from database.

Can you help me ?


Thanks
Reply With Quote
  #2  
Old 13-07-2009
Member
 
Join Date: Jan 2009
Posts: 10
Re: How to create loop query sql ?

fgets function returns an entire line of a file, up to meet a newline (character \ n). The problem is precisely that it returns the \ n with! So in your comparison between the field of comics and the variable $ line, and you are with a character too
Reply With Quote
  #3  
Old 13-07-2009
Member
 
Join Date: Dec 2008
Posts: 28
Re: How to create loop query sql ?

Transact-SQL statement or statement grouping as defined with a statement block. To define a statement block, use the control-of-flow keywords BEGIN and END.

BREAK

Causes an exit from the innermost WHILE loop. Any statements that appear after the END keyword, marking the end of the loop, are executed.

CONTINUE

Causes the WHILE loop to restart, ignoring any statements after the CONTINUE keyword.

Example

Code:
DECLARE Employee_Cursor CURSOR FOR
SELECT EmployeeID, Title 
FROM AdventureWorks.HumanResources.Employee
WHERE ManagerID =3;
OPEN Employee_Cursor;
FETCH NEXT FROM Employee_Cursor;
WHILE @@FETCH_STATUS = 0
   BEGIN
      FETCH NEXT FROM Employee_Cursor;
   END;
CLOSE Employee_Cursor;
DEALLOCATE Employee_Cursor;
GO
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to create loop query sql ?"
Thread Thread Starter Forum Replies Last Post
Create batch file to run access query DeMario Software Development 5 31-12-2009 04:44 AM
How to create a query on datagrid view in vb.net Ainsley Software Development 3 10-12-2009 09:59 PM
Create FLV video loop Dyumani Windows Software 3 19-05-2009 11:16 AM
How to create 7 days query in MySql Patrickboy Software Development 2 18-05-2009 02:02 PM
How to create a script in a DOS batch file to do a loop? Jon Osborn Windows Server Help 2 27-05-2008 06:41 PM


All times are GMT +5.5. The time now is 03:32 AM.