atomicrabbit Posted September 8, 2008 Share Posted September 8, 2008 I found this http://kids-n-fun.blogspot.com/2006/12/query-number-of-rows-sql-server.html and was wondering how to use it. The select statement is this: SELECT rows FROM sys.sysindexes WHERE (id = OBJECT_ID('tablename')) AND (name = 'PrimaryKey name') And apparently it's quicker becuase you "select only one row". But after replacing 'tablename' and 'PrimaryKey name' with the appropriate information, the query came back with an error (#1064). I also tried replacing sys.sysindexes with my_db_name.tablename but it still did not work. What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
atomicrabbit Posted September 9, 2008 Author Share Posted September 9, 2008 anyone? Quote Link to comment Share on other sites More sharing options...
severndigital Posted September 9, 2008 Share Posted September 9, 2008 are you using MySQL or SQL?? The title of that post is number of rows in SQL query. Not sure if it matters, but the way that query is formatted it will never work properly in my experiences with MySQL. Quote Link to comment Share on other sites More sharing options...
atomicrabbit Posted September 9, 2008 Author Share Posted September 9, 2008 ahhhh... that makes sense... I'm using MySQL. so is the easiest/quickest way to return the number of rows in MySQL to do a SELECT count(*) as num FROM table_name ? btw, Thanks for the reply Quote Link to comment Share on other sites More sharing options...
fenway Posted September 10, 2008 Share Posted September 10, 2008 so is the easiest/quickest way to return the number of rows in MySQL to do a SELECT count(*) as num FROM table_name ? yes. Quote Link to comment Share on other sites More sharing options...
atomicrabbit Posted September 10, 2008 Author Share Posted September 10, 2008 thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.