Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

i am trying to show info from two tables in a listview in vb.net, and the sql statement needs a left join statement to join the two tables.

I need help with the code. PLEASE

Posted
  Quote
i am trying to show info from two tables in a listview in vb.net, and the sql statement needs a left join statement to join the two tables.

I need help with the code. PLEASE

 

Do you have MS Access?

 

Without trying to sidestep, that is by far the easiest way to learn these things.

 

You make your query in design view and right click and choose SQL. MSDE probobly wouldn't have these features, but SQL Server XXXX better damn well have them for that price!

 

Here is what I got from access for a two table showing One to Many:

 

SELECT 
FROM <OneTable> INNER JOIN <ManyTable> ON <OneTable.Key> = <ManyTable.ForeignKey>;

 

Hope that helps a little.

Posted
  Quote

SELECT

FROM <OneTable> INNER JOIN <ManyTable> ON <OneTable.Key> = <ManyTable.ForeignKey>;

 

You should probably change INNER JOIN to LEFT OUTER JOIN (since that's what was required in the original post). And, of course, don't forget the field list following the SELECT clause.

Posted
  Quote
What's the difference between LEFT INNER JOIN and INNER JOIN?

There is not such thing as a LEFT INNER JOIN, just INNER JOIN or simply JOIN. Only OUTER joins have a directional keyword like LEFT, RIGHT or FULL and the SQL-92 standard defines these keywords as equivalent:

 

LEFT OUTER JOIN or LEFT JOIN

RIGHT OUTER JOIN or RIGHT JOIN

FULL OUTER JOIN or FULL JOIN

 

Then there are cross joins also known as cartesian products, like when you just specify the tables without indicating a join like this:

 

SELECT * FROM tableone, tabletwo

 

HTH

Posted
  Quote
What's the difference between LEFT INNER JOIN and INNER JOIN?

 

From SQL Server Books Online:

 

"Inner joins return rows only when there is at least one row from both tables that matches the join condition. Inner joins eliminate the rows that do not match with a row from the other table. Outer joins, however, return all rows from at least one of the tables or views mentioned in the FROM clause, as long as those rows meet any WHERE or HAVING search conditions. All rows are retrieved from the left table referenced with a left outer join, and all rows from the right table referenced in a right outer join. All rows from both tables are returned in a full outer join"

 

And as mentioned by akiaz, there's no such thing as a LEFT INNER JOIN.

Posted
  Quote

And as mentioned by akiaz, there's no such thing as a LEFT INNER JOIN.

 

Yeah, my mistake. I misread what you wrote. I thought you wrote that my INNER JOIN was wrong, but should be LEFT INNER JOIN. You wrote LEFT OUTER JOIN.

 

I should stick my nose out of things I don't understand really. I thought he just ment "Join" and was trying to help. Sorry :(

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...