|
| |||||||||
| Tags: loop, query sql |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| 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 />'; ) Can you help me ? Thanks |
|
#2
| |||
| |||
| 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 |
|
#3
| |||
| |||
| 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 |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to create loop query sql ?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 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 12:16 PM |
| How to create 7 days query in MySql | Patrickboy | Software Development | 2 | 18-05-2009 03:02 PM |
| Sysprep Create Reboot Loop | mountnco | Vista Setup and Install | 13 | 06-02-2009 02:03 PM |
| How to create a script in a DOS batch file to do a loop? | Jon Osborn | Windows Server Help | 2 | 27-05-2008 07:41 PM |