Announcement

Collapse
No announcement yet.

[HELP] Count all data in a table in SQLITE3

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • kadel
    replied

    Using MySQL would be

    Code:
    MySQLCursor, err = MySQLConnection:execute("SELECT COUNT(*) FROM Students WHERE YearID='"..sYearID.."' ");
    if not err then
    Count = MySQLCursor:fetch({},"n");
    Dialog.Message("Notice", Count[1], MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    else Dialog.Message("Error", err); return "Error"; end

    Leave a comment:


  • telco
    replied
    Hi colc thank you.. it works for me, it solve my problem... Have a great day...

    Leave a comment:


  • colc
    replied
    Hey telco ,
    Would help if you posted example of your apz or at least example db
    off top of my head maybe try something like this

    Code:
    testCount = 0
    -- loop until we get all the information from database
    local q = "SELECT * FROM FROM Students WHERE YearID = '"..sYearID.."' "
    for row in db:nrows(q) do
    --Get the data by fields from the database
     nCount = row.YearID
        if nCount == 3 then
        testCount = testCount + 1
    end
    
    Dialog.Message("Notice", tostring(testCount), MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

    Leave a comment:


  • telco
    replied
    testCount = db:exec("SELECT COUNT(*) FROM Students WHERE YearID = '"..sYearID.."' ) ")

    result = Dialog.Message("Notice", tostring(testCount), MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);


    i have more than 20 students save in specific year level but in the dialog message it only returns 1 item.

    can anyone help me get the correct syntax to count all students in specific year?




    Thank you so much

    Leave a comment:


  • telco
    replied
    anyone can help me?

    Leave a comment:


  • telco
    started a topic [HELP] Count all data in a table in SQLITE3

    [HELP] Count all data in a table in SQLITE3

    hi i need help in sqlite3 how can it get return value of number count of all the list in table

    example; studentCount = (Select count(Student) From Student Where YearLevel = 3)

    i want to get all the numbers count of all the student in year level 3 and put it in studentCount

    thank you
Working...
X