-
January 21st, 2015, 10:58 AM
#1
[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.
-
January 21st, 2015, 11:44 AM
#2
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?
-
January 21st, 2015, 01:57 PM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|