KeenEyeLearner Posted May 30, 2006 Share Posted May 30, 2006 Hi If i have a table [ named : TAB1 with columns C1,C2,C3 ] and i want to see the value of the first row only, what would be the query.I know that this works..--> select C1,C2,C3 from (select C1,C2,C3,rownum rn from TAB1) where rn<=1;But this is too long. I tried this, but it did not work. --> select top 1 from TAB1;Any help please......Thanks Link to comment Share on other sites More sharing options...
aspnetguy Posted May 30, 2006 Share Posted May 30, 2006 MSSQL SELECT TOP 1 * FROM tablename MySQL SELECT * FROM tablename LIMIT 1 Link to comment Share on other sites More sharing options...
Jack McKalling Posted May 30, 2006 Share Posted May 30, 2006 MySQL: SELECT * FROM tablename ORDER BY indexcolumn LIMIT 1 Link to comment Share on other sites More sharing options...
aspnetguy Posted May 30, 2006 Share Posted May 30, 2006 MySQL:SELECT * FROM tablename ORDER BY indexcolumn LIMIT 1 <{POST_SNAPBACK}> Doesn't it do that automatically if you don't specify an ORDER BY??? MSSQL does anyways. Link to comment Share on other sites More sharing options...
Jack McKalling Posted May 30, 2006 Share Posted May 30, 2006 In case you have a table with a custom index (a column containing unique alphanumeric characters) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now