In MySQL, the LIMIT clause is usually the very LAST part of any query. I would put it here:
/* Logic goes here for Offset parsing */ PRINTF (s_Where, "WHERE iv_alert.uuid > %d ORDER BY iv_alert.uuid ASC", i_Offset ) Right after the ASC. This should limit you to only 10000 responses: ...ORDER BY iv_alert.uuid ASC LIMIT 10000", i_Offset) If you read about it (http://dev.mysql.com/doc/mysql/en/SELECT.html) you see that it can help you with results "paging" as well ...ORDER BY iv_alert.uuid ASC LIMIT 10000, 1000", i_Offset) That will give you the next 1000 records starting from record # 10001 (it's a zero-based number. First record = 0) . Yours, Shawn Green Database Administrator Unimin Corporation - Spruce Pine "Kamal Ahmed" <[EMAIL PROTECTED]> wrote on 07/29/2004 02:16:12 PM: > Shawn, > > Thanks for your help, I was wondering, if you can make any sense out > of WHERE should I insert the TOP Commands, in the snippet below. > Although this code is specific to our application, but maybe you can > help me with this. > > Thanks, and I really appreciate your help. > > -Kamal. > > > > /* Build the Table Name(s) > Microsoft SQL command - > SELECT iv_sensor_names.name, iv_attack_0.name, iv_alert_type_0.name, > iv_alert_severity_0.name, iv_categories_0.displayableName, > iv_subcategories_0.display_name, iv_detection_0.displayableName, > iv_direction_0.displayableName, iv_result_set_0.displayableName, > iv_alert_0.creationTime > FROM iv_alert iv_alert_0, iv_alert_severity iv_alert_severity_0, > iv_alert_type iv_alert_type_0, iv_attack iv_attack_0, iv_categories > iv_categories_0, iv_detection iv_detection_0, iv_direction > iv_direction_0, iv_result_set iv_result_set_0, iv_sensor_names > iv_sensor_names_0, iv_subcategories iv_subcategories_0 > WHERE iv_alert_0.sensorId = iv_sensor_names_0.sensor_id AND > iv_alert_0.alertType = iv_alert_type_0.id AND iv_alert_0.severity = > iv_alert_severity_0.id AND iv_alert_0.attackIdRef = iv_attack_0.id > AND iv_alert_0.categoryId = iv_categories_0.categoryId AND > iv_alert_0.subCategoryId = iv_subcategories_0.idnum AND iv_alert_0. > detectionMechanism = iv_detection_0.detectionMechanism AND > iv_alert_0.resultSetValue = iv_result_set_0.resultSetValue AND > iv_alert_0.direction = iv_direction_0.direction > Table Joins - > iv_alert LEFT JOIN iv_sensor_names ON iv_alert.sensorId = > iv_sensor_names.sensor_id > iv_alert LEFT JOIN iv_alert_type ON iv_alert.alertType = iv_alert_type.id > iv_alert LEFT JOIN iv_alert_severity ON iv_alert.severity = > iv_alert_severity.id > iv_alert LEFT JOIN iv_attack ON iv_attack.attackIdRef = iv_attack.id > iv_alert LEFT JOIN iv_categories ON iv_alert.categoryId = > iv_categories.categoryId > iv_alert LEFT JOIN iv_subcategories ON iv_alert.subCategoryId = > iv_subcategories.idnum > iv_alert LEFT JOIN iv_detection ON iv_alert.detectionMechanism = > iv_detection.detectionMechanism > iv_alert LEFT JOIN iv_result_set ON iv_alert.resultSetValue = > iv_result_set.resultSetValue > iv_alert LEFT JOIN iv_direction ON iv_alert.direction = iv_direction.direction > Need LIMIT i_Max_Rows_To_Return > */ > BREAKPOINT() > PRINTF(s_Table, "iv_alert LEFT JOIN iv_sensor_names ON iv_alert. > sensorid = iv_sensor_names.sensor_id ") > APPEND(s_Table: "LEFT JOIN iv_alert_type ON iv_alert.alertType = > iv_alert_type.id ") > APPEND(s_Table: "LEFT JOIN iv_alert_severity ON iv_alert.severity = > iv_alert_severity.id ") > APPEND(s_Table: "LEFT JOIN iv_attack ON iv_alert.attackIdRef = iv_attack.id ") > APPEND(s_Table: "LEFT JOIN iv_categories ON iv_alert.categoryId = > iv_categories.categoryId ") > APPEND(s_Table: "LEFT JOIN iv_subcategories ON iv_alert. > subCategoryId = iv_subcategories.idnum ") > APPEND(s_Table: "LEFT JOIN iv_detection ON iv_alert. > detectionMechanism = iv_detection.detectionMechanism ") > APPEND(s_Table: "LEFT JOIN iv_result_set ON iv_alert.resultSetValue > = iv_result_set.resultSetValue ") > APPEND(s_Table: "LEFT JOIN iv_direction ON iv_alert.direction = > iv_direction.direction") > /* Build the Where line */ > CLEAR(s_Where) > /* Logic goes here for Offset parsing */ > PRINTF (s_Where, "WHERE iv_alert.uuid > %d ORDER BY iv_alert.uuid > ASC", i_Offset ) > /* Build the Column Names list */ > PRINTF(s_Columns0, " iv_alert.uuid, iv_sensor_names.name, iv_attack. > name, iv_alert_type.name, iv_alert_severity.name, iv_categories. > displayableName, " ) > PRINTF(s_Columns1, " iv_subcategories.display_name, iv_detection. > displayableName, iv_direction.displayableName, iv_result_set. > displayableName, iv_alert.creationTime, ") > PRINTF(s_Columns2, " iv_alert.targetIPAddr, iv_alert.targetPort, > iv_alert.sourceIPAddr, iv_alert.sourcePort, iv_alert.networkProtocolId ") > PRINTF(s_Columns, "%s%s%s", s_Columns0, s_Columns1, s_Columns2) > BREAKPOINT() > /* > - DO NOT CHANGE THE LINES BELOW - > */ > LOOKUP("SelectDB_CheckStatus","eSecurity_Actions") > SET(i_Record_Counter = 0) > > -------------------------------------------------------------------------------------------- > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 28, 2004 2:44 PM > To: Kamal Ahmed > Cc: [EMAIL PROTECTED] > Subject: Re: TOP > > In MS SQL Server (T-SQL) you say > SELECT TOP n ........ > > In MySQL you use: > > SELECT .... LIMIT n > > (http://dev.mysql.com/doc/mysql/en/SELECT.html) > > There is no direct equivalent to SELECT TOP n PERCENT.... > > Yours, > Shawn Green > Database Administrator > Unimin Corporation - Spruce Pine > > "Kamal Ahmed" <[EMAIL PROTECTED]> wrote on 07/28/2004 02:39:11 PM: > > > Hi, > > Does anyone know how to do a TOP function in MySQL ? > > > > Thanks, > > > > -Kamal. > > > > -- > > MySQL General Mailing List > > For list archives: http://lists.mysql.com/mysql > > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > >