List:MySQL++« Previous MessageNext Message »
From:Ibrahim Mubarak Date:January 15 2005 5:25pm
Subject:Re: Simple query problem
View as plain text  
--- Zahroof Mohamed <zahroofm@stripped> wrote:

> I'd like to access a row in a table. The primary key column is named
> "id". I'd like to use a query which passes the specific id as a
> variable. It appears that I can do this:
> int iID = 1000;
> query << "SELECT * FROM table WHERE id = " << iID;
> By executing this query could I get the row corresponding to id = 1000?

You answered your own question! By executing this query, you will get the row(s) where id
= 1000.
Check example complic1.cpp. It shows how to use the store method of the Query object (=
the query) that puts the results in a Result object. It also shows how to use a Row object
to get
the info from the Result object.

> Can anyone point me to where I can find information about how I would
> pass other types of variables - such as a double, string or a date
> etc. Didn't find anything in the examples or in the manual.

Strings, doubles, floats, chars, and the like are straight forward. Just do it like the
example you brought up. However, for more complicated types such as dates I am not sure
how to go
about it. Maybe someone with greater experience in this than me can help you out.


Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less.
RELEASE: v1.7.27Warren Young12 Jan
  • Simple query problemZahroof Mohamed14 Jan
    • Re: Simple query problemIbrahim Mubarak15 Jan