Solved

VB.net SQL See all in one table

Posted on 2014-09-26
3
180 Views
Last Modified: 2014-09-26
I am building the following SQL statement to see everything in my BANK table that has the same [LINK ID] as
my Payments table and everything in my Payments table (Linked and not linked). I am not seeing some items
in my Payments table. Shouldn't I see everything from that side


            Dim sSQL As String
            sSQL = "Select Bank.*, Payments.*"
            sSQL = sSQL & " From Bank Right Join Payments on Bank.[LINK ID] = Payments.[LINK ID]"
0
Comment
Question by:murbro
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40345637
Select Bank.*, Payments.*"

will/would very likely result in "duplicate" column names in the result
as consequence, some db drivers will either
* raise an error
* rename the columns,
* skip the columns
* fill the columns with the same data as previous column

the only way to solve this out is to write a SQL that avoids duplicate column names, hence not using table.* in your select
the "workaround" I usually use is that I do this inside a view on the database side, and the application then does the select * from view_name, this way I could add new columns to the tables/views without breaking the application code and without having to deploy a new exe ...
0
 
LVL 3

Expert Comment

by:PrisonBroken
ID: 40345671
I always work with a left join but yes that looks like it should work.

Which specific rows are not showing up, is there a commonality in those that might help figure out why they are not returned?
0
 

Author Closing Comment

by:murbro
ID: 40345681
Thanks
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question