Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Number of Records [modified]

Number of Records [modified]

Scheduled Pinned Locked Moved Database
databasesqlitetutorialquestion
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    T RATHA KRISHNAN
    wrote on last edited by
    #1

    Hi! How to get the total records in a table? The following query returns an irrelevant number like 39685832(not the same all the time). I'm using SQLite. How to get the no.of records from a SQLite table?

    "SELECT COUNT(*) FROM current"

    modified on Tuesday, October 5, 2010 7:23 AM

    N 1 Reply Last reply
    0
    • T T RATHA KRISHNAN

      Hi! How to get the total records in a table? The following query returns an irrelevant number like 39685832(not the same all the time). I'm using SQLite. How to get the no.of records from a SQLite table?

      "SELECT COUNT(*) FROM current"

      modified on Tuesday, October 5, 2010 7:23 AM

      N Offline
      N Offline
      NeverHeardOfMe
      wrote on last edited by
      #2

      Your table does have a primary key field, or unique index at least, doesn't it? Try counting on that, eg

      SELECT COUNT(ID) FROM tablename

      Is "current" really your table name? I am not sure about suing that... it is a reserved word[^] - at least try enclosing it in delimters if you must use that name. Otherwise, change it.

      T 1 Reply Last reply
      0
      • N NeverHeardOfMe

        Your table does have a primary key field, or unique index at least, doesn't it? Try counting on that, eg

        SELECT COUNT(ID) FROM tablename

        Is "current" really your table name? I am not sure about suing that... it is a reserved word[^] - at least try enclosing it in delimters if you must use that name. Otherwise, change it.

        T Offline
        T Offline
        T RATHA KRISHNAN
        wrote on last edited by
        #3

        Hi! This query doesn't work. Actually I'm passing SQLite query from C++. When I run my C++ program, it crashes and the console displays "SQLError: No such column ID". I've tested this with another table(profile instead of current)also. How to get the number of rows in a table?

        N 1 Reply Last reply
        0
        • T T RATHA KRISHNAN

          Hi! This query doesn't work. Actually I'm passing SQLite query from C++. When I run my C++ program, it crashes and the console displays "SQLError: No such column ID". I've tested this with another table(profile instead of current)also. How to get the number of rows in a table?

          N Offline
          N Offline
          NeverHeardOfMe
          wrote on last edited by
          #4

          Well use the name of a column you do have then, if ytou haven't got an ID field. :doh:

          T 1 Reply Last reply
          0
          • N NeverHeardOfMe

            Well use the name of a column you do have then, if ytou haven't got an ID field. :doh:

            T Offline
            T Offline
            T RATHA KRISHNAN
            wrote on last edited by
            #5

            Can you tell me the type(INTEGER or TEXT) that the above query returns?

            N T 2 Replies Last reply
            0
            • T T RATHA KRISHNAN

              Can you tell me the type(INTEGER or TEXT) that the above query returns?

              N Offline
              N Offline
              NeverHeardOfMe
              wrote on last edited by
              #6

              It should return an integer

              1 Reply Last reply
              0
              • T T RATHA KRISHNAN

                Can you tell me the type(INTEGER or TEXT) that the above query returns?

                T Offline
                T Offline
                T RATHA KRISHNAN
                wrote on last edited by
                #7

                It's printed correctly. Query's return type is an array string(I've implemented like that). So, I've to convert it to int using atoi.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups