SELECT * FROM `studentcourse` WHERE `systemcode` = 'ilscorp' AND `status` = 'complete' AND `techcode` IN (SELECT `techcode` FROM `usersubscription` WHERE `subscription_id` = '296')


After I run this the server has an intense lag and needs to be restarted or timeoutes occur.

SELECT * FROM `studentcourse` WHERE `systemcode` = 'ilscorp' AND `status` = 'complete' AND `techcode` IN (SELECT `techcode` FROM `usersubscription` WHERE `subscription_id` = '296')

I don't think you need to use single qoutes on variable names, they are used only on variable values when listed. Your query should be like this

SELECT * FROM studentcourse WHERE systemcode = 'ilscorp' AND status = 'complete' AND techcode IN (SELECT techcode FROM usersubscription WHERE subscription_id = '296')

Hey I appreciate the reply, but removing backticks didn't change the behavoir of the query

Where do you use this query? Which database? In what enviroment(PHP to DB, servlets to DB)?

I've tried it in PHPMYADMIN

and in my PHP script:

$select_results = mysql_query("SELECT * FROM `studentcourse` WHERE `systemcode` = 'ilscorp' AND `status` = 'complete' AND `techcode` IN (SELECT `techcode` FROM `usersubscription` WHERE `subscription_id` = '$subid')") or die("<BR>Failed to run MySQL query!<BR>".mysql_error().$form);

phpMyAdmin - 2.9.0.2

MySQL client version: 5.0.24a

PHP Version 5.1.6

is it only timeout and lag what you get, or some error message pop-up?