Page 2 of 2

Posted: Mon Jan 16, 2006 1:00 am
by Extremest
ok if I have this query in mssql to get the result I want how do I use it to make an update with out doing each update individually.

Code: Select all

SELECT id, url FROM (
SELECT TOP ($x) id, url FROM (
SELECT TOP ($x) id, url FROM $table WHERE (done = 0) ORDER BY id) AS newtbl      ORDER BY id DESC) AS newtbl2 ORDER BY id

Posted: Mon Jan 16, 2006 1:22 am
by Extremest
Nevermind. These 2 queries will work and the select is shorter.

Code: Select all

$q = "SELECT TOP ($x) url FROM $table WHERE (url NOT IN (SELECT TOP (0) url FROM $table AS spider_1 ORDER BY id)) AND (done = '0') ORDER BY id";

$d = "UPDATE $table SET done = 1 WHERE (url IN (SELECT TOP ($x) url FROM $table AS wwwebayfr_1 WHERE (url NOT IN (SELECT TOP (0) url FROM $table AS spider_1 ORDER BY id)) AND (done = '0') ORDER BY id))";

Posted: Mon Jan 16, 2006 1:27 am
by Extremest
Does there happen to be a workaround for mssql for mysql's insert ignore?