?
Solved

VB.net SQL See all in one table

Posted on 2014-09-26
3
Medium Priority
?
189 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:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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:Murray Brown
ID: 40345681
Thanks
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

764 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