Worst use of query

by saravana 2014-08-30 17:38:39

Query 1:

Wrong:
 
for(int i=0; i<query("SELECT COUNT ...."); i++)
{
    //code..
}

This query iterates n times til the loop ends. And result of the query doesn't change.

Correct:
 
count = query("SELECT COUNT ....");

for(int i=0; i<count; i++)
{
    //code..
}


Query 2:

DELETE FROM table;

This query contain no where clause.
Before execute the query delete or update just select and check the right row is affecting.

Query 3:
 
SELECT * FROM sometable 
WHERE field LIKE '%something' 
OR LIKE 'something%' 
OR LIKE '%something%';

This query contains 3 like condition. Third condition selects first and second condition selects.

Query 4:
 
select * from users where clue > 0;
0 results found.
It never returns any results, no matter where and why you run it.

Query 5:
 
select * from *
Very bad.

Query 6:
 
DROP DATABASE;
ROLLBACK;

Really very bad.
1356
like
0
dislike
0
mail
flag

You must LOGIN to add comments