CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2015
    Posts
    4

    [Help] Join Two Tables

    Hello
    I have problem with inner join..
    With a simple query, like:
    Select * from movies .. all works great.
    But now, i need use two tables, movie and director.
    How can i do it? I think i need other mapping, but i don't know where i need put.
    All help is appreciated.

    Code:
            public static List<Movie> GetMovieByDirector()
            {
                List<Movie> res = new List<Movie>();
    
                using (DB db = new DB(hostnameDB, userDB, passwordDB, database))
                {
                    string query = string.Format("SELECT {0}.Name_Movie, {0}.Director_id, {1}.Id, {1}.Name_Director from {0} INNER JOIN {1} ON {0}.Director_id={1}.id AND {1}.Name_Director=@Name_Director", table, table2);
                    Dictionary<string, object> parms = new Dictionary<string, object>();
    .....
    Last edited by J4yJ4y; January 26th, 2015 at 09:41 PM.

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: [Help] Join Two Tables

    This sounds more like a question concerning SQL and relational databases rather than a question on C++. If so, a moderator might move this thread.

    What are the relevant fields from the movie and director tables and how are they related? What exactly are you trying to retrieve through the join?
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Jan 2015
    Posts
    4

    Re: [Help] Join Two Tables

    Hi, thanks for your reply.

    Everything is good with sql.
    My problem is show content of two tables in ListView. I wanna search by Director (name) and show all results.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured