Solved

VB.net SQL See all in one table

Posted on 2014-09-26
3
174 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 142

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now