johnsmith153 Posted October 28, 2009 Share Posted October 28, 2009 (1.) Is there a limit to the length of a sql query I can use in MySQL? I have an array of id numbers (could be up to thousands). I want to delete all these id numbers from a table. I.e. query something like: $sql = "DELETE FROM tableName WHERE 1 LIKE 2"; foreach ($array as $a) { $sql .= sprintf(" OR field LIKE '%s'",mysql_real_escape_string($a)); } - Is this the best way? - What if I had thoudands of id numbers to delete. Will the query length be an issue? - Will any PHP.ini settings affect size of query allowed? (2.) Which PHP.ini settings will affect size of database data returned? Previously to now I have only changed "memory_limit". There are occasions when I dump a whole load of database data to PHP. Do I need to change anyting else to allow a database dump of 1 million records? Link to comment https://forums.phpfreaks.com/topic/179349-max-query-size/ Share on other sites More sharing options...
cags Posted October 28, 2009 Share Posted October 28, 2009 You might be better off using the IN keyword rather than lots of OR statements. I'd have also thought you wouldn't want to use LIKE since you are making an exact comparison I'd have thought just using = would be better. Link to comment https://forums.phpfreaks.com/topic/179349-max-query-size/#findComment-946303 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.