Help with Query

Discussion in 'Programming' started by NFreak, Feb 27, 2009.

  1. #1
    I'm doing a MySQL embedded into C++ project and I am having a minor issue.

    I can use my row[0] through row[x] array, where x is the number of columns-1 in the table.

    For example:

    ID USERNAME PASSWORD
    15 NFreak ******

    row[0] will equal 15
    row[1] will equal NFreak, etc...

    Now I needed grab a value from the table that was not already in the table. For example,

    ID COST QUANTITY
    12 12.95 3

    row[1] * row[2] is what I want (the cost times the quantity).

    However, I can't display row[1] * row[2] because they are char *'s, as c++ does not share the same datatypes as mysql.

    Does anyone know of a way for me to grab row[1]*row[2].

    SELECT COST,QUANTITY,@TOTAL FROM table WHERE @TOTAL:=(COST*QUANTITY)

    I ran a query like that, but row[2] in that case is not equal to @TOTAL like I would like it to be.

    Please help, and thank you. :)
     
    NFreak, Feb 27, 2009 IP