Select the first row with specific column value
i have a table being accessed by multiple threads. The table contains a column with the row status i.e "Dialed" if it had already been processed and "Not Dialled" if it isn't . I would want to
Select first row where status = "not Dialled" (Read Past ).
I am using readpast so that multiple threads can have different rows and no deadlock happens.
Is the use of Read Past ok here and secondly how can I get the first row always
You can simply use "Top" clause like this.
Select Top 1 * From Data Where status = "not Dialled" ;
The TOP clause is used to specify the number of records to return. Note: Not all database systems support the TOP clause.
SQL Server Syntax: SELECT TOP number|percent column_name(s) FROM table_name
MySQL Syntax: SELECT column_name(s) FROM table_name LIMIT number Example
Oracle Syntax: SELECT column_name(s) FROM table_name WHERE ROWNUM <= number
Further Reference: http://www.w3schools.com/sql/sql_top.asp