Forum Moderators: coopster
$query = "SELECT widget_type FROM $database WHERE widget_type = 'A'";
$result = mysql_query( $query );
$row = mysql_fetch_array( $result );if( $row[ 'widget_type' ] == '' ) { $has_widget_type = false; }
else { $has_widget_type = true; }
Lets say I have 300 parts that have widget_type A, will the query find the first one and then just stop or will it continue to search the whole database until it finds all widgets with widget_type A?
If it is searching the whole database, is there a way to make it stop as soon as it finds the first instance of widget_type A?
SET ROWCOUNT = 1
SELECT whatever from wherever order by whoever
Set Rowcount also works when doing UPDATES and DELETES, since you can't do "UPDATE TOP" or "DELETE TOP" ... want to delete the first 50 records?
SET ROWCOUNT = 50
DELETE FROM [wherever] WHERE ... etc.
If you're using ADO or doing this through a script, use a chr(10) in your SQL statement to separate the lines.
SQL = "SET ROWCOUNT = 50" & chr(10) & "SELECT WHATEVER...."
or
SQL = "SET ROWCOUNT = 50" & chr(10)
SQL = SQL & "SELECT WHATEVER..."