MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:wang tianyi Date:October 18 2002 7:29am
Subject:RE: about use Dev-cpp and C++
View as plain text  
very thank you !:)
if i have more question will ask you again.


thank you again!



> Subject:    RE: about use Dev-cpp and C++
> 
> > what's nested SQL?
> > can you tell me more about it?
> 
> Nested SQL allows you to do all kinds of interesting things in MySQL
> that you can't do now - sub-selects, for example; or if you're a lazy
> programmer (like me!) you want to do grouping and sorting in ways that
> would be difficult (and complicated) with an ordinary SQL query.
> 
> For example, suppose you had two tables - a users table and a messages
> table.  You suspect that you've got orphaned records in the messages
> table, but you're not sure.  You also want to do other stuff to each
> message as you go through it.  So, you decide that you want to iterate
> through each record in the users table, setting a flag in the messages
> table for each message that isn't orphaned:
> 
> char cmd[256];
> 
> /* you could also do an ExecuteSQL() here, too */
> OpenRecordset("update messages set OK='N'");
> CloseRecordset();
> /* or ExecuteSQL ("update messages set OK='N'"); */
> OpenRecordset("select * from users");
> while(RecordsetEOF() != EOF)
> {
>     /* ID in the users table has a one-to-many relationship to usersID
> in the messages table */
>     sprintf(cmd, "update messages set OK='Y' where usersID=%s",
> GetField("ID"));
>     OpenRecordset(cmd);
>     CloseRecordset();
>     /* could also do a ExecuteSQL(cmd); */
>     MoveNext();
> }
> CloseRecordset();
> /* now, we want to see which records are orphaned */
> OpenRecordset("select * from messages where OK='Y'");
> while(RecordsetEOF() != EOF)
> {
>     /* do whatever here */
>     MoveNext();
> }
> CloseRecordset();
> 
> Of course, this is a simple example.  PLEASE DON'T POST QUERIES SHOWING
> HOW THIS COULD BE DONE EASIER OR FASTER OR WHATEVER IN SQL!  I'm sure
> you can think of a lot of other examples where doing a sub-select would
> be very cool, but MySQL doesn't support it.
> 
> sql, query


Thread
about use Dev-cpp and C++wang tianyi14 Oct
  • Re: about use Dev-cpp and C++Insanely Great14 Oct
  • Re: about use Dev-cpp and C++Michael T. Babcock16 Oct
    • RE: about use Dev-cpp and C++Ed Carp16 Oct
      • RE: about use Dev-cpp and C++wang tianyi18 Oct
        • RE: about use Dev-cpp and C++Ed Carp18 Oct
          • RE: about use Dev-cpp and C++wang tianyi18 Oct
    • Re: about use Dev-cpp and C++wang tianyi18 Oct